StreamErrorRecovery<T> extension
Stream Error Recovery Extensions
Provides error recovery strategies on Stream, including retry logic with exponential backoff and alternative recovery modes.
The following methods are available:
- retry: Resubscribes to the source stream when an error occurs, up to a maximum number of attempts.
- replaceOnError: Replaces an error event with a provided default value, then completes.
- completeOnError: Completes the stream immediately upon an error.
Example:
// Retry up to 3 times with an initial delay of 1 second.
myStream.retry(retryCount: 3, delayFactor: Duration(seconds: 1))
.listen(print, onError: print);
- on
-
- Stream<
T>
- Stream<
Methods
-
completeOnError(
) → Stream< T> -
Available on Stream<
Completes the stream immediately upon an error, swallowing the error.T> , provided by the StreamErrorRecovery extension -
replaceOnError(
{required T defaultValue}) → Stream< T> -
Available on Stream<
Replaces an error event withT> , provided by the StreamErrorRecovery extensiondefaultValueand then completes the stream. -
retry(
{int retryCount = 3, Duration delayFactor = const Duration(seconds: 1), bool shouldRetry(Object error)?}) → Stream< T> -
Available on Stream<
Retries the stream subscription in case of error.T> , provided by the StreamErrorRecovery extension