Observable<T>.retry constructor

Observable<T>.retry(
  1. Stream<T> streamFactory(
      ),
    1. [int count]
    )

    Creates an Observable 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

    new Observable.retry(() { new Observable.just(1); })
        .listen((i) => print(i)); // Prints 1
    
    new Observable
       .retry(() {
         new Observable.just(1).concatWith([new Observable.error(new Error())]);
       }, 1)
       .listen(print, onError: (e, s) => print(e)); // Prints 1, 1, RetryError
    

    Implementation

    factory Observable.retry(Stream<T> streamFactory(), [int count]) {
      return Observable<T>(RetryStream<T>(streamFactory, count));
    }