retry<T> method
- Stream<
T> streamFactory( - [int count]
Creates a Stream
that will recreate and re-listen to the source
Stream the specified number of times until the Stream terminates
successfully.
If the retry count is not specified, it retries indefinitely. If the retry count is met, but the Stream has not terminated successfully, a RetryError will be thrown. The RetryError will contain all of the Errors and StackTraces that caused the failure.
Example
Rx.retry(() => Stream.value(1))
.listen((i) => print(i)); // Prints 1
Rx.retry(
() => Stream.value(1).concatWith([Stream.error(Error())]),
1,
).listen(print, onError: (e, s) => print(e)); // Prints 1, 1, RetryError
Implementation
static Stream<T> retry<T>(Stream<T> Function() streamFactory, [int count]) =>
RetryStream<T>(streamFactory, count);