282fb6064a43614c483c9eb6c9edba982d6fc68a3e0b9c7bd5e771f9edc21b21f79a73da73e7041fcd5e971300cb13a20f01dc8fad2ec18a90486caf99df14 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Observable } from '../Observable';
  2. import { MonoTypeOperatorFunction, ObservableInput } from '../types';
  3. /**
  4. * Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable
  5. * calls `error`, this method will emit the Throwable that caused the error to the `ObservableInput` returned from `notifier`.
  6. * If that Observable calls `complete` or `error` then this method will call `complete` or `error` on the child
  7. * subscription. Otherwise this method will resubscribe to the source Observable.
  8. *
  9. * ![](retryWhen.png)
  10. *
  11. * Retry an observable sequence on error based on custom criteria.
  12. *
  13. * ## Example
  14. *
  15. * ```ts
  16. * import { interval, map, retryWhen, tap, delayWhen, timer } from 'rxjs';
  17. *
  18. * const source = interval(1000);
  19. * const result = source.pipe(
  20. * map(value => {
  21. * if (value > 5) {
  22. * // error will be picked up by retryWhen
  23. * throw value;
  24. * }
  25. * return value;
  26. * }),
  27. * retryWhen(errors =>
  28. * errors.pipe(
  29. * // log error message
  30. * tap(value => console.log(`Value ${ value } was too high!`)),
  31. * // restart in 5 seconds
  32. * delayWhen(value => timer(value * 1000))
  33. * )
  34. * )
  35. * );
  36. *
  37. * result.subscribe(value => console.log(value));
  38. *
  39. * // results:
  40. * // 0
  41. * // 1
  42. * // 2
  43. * // 3
  44. * // 4
  45. * // 5
  46. * // 'Value 6 was too high!'
  47. * // - Wait 5 seconds then repeat
  48. * ```
  49. *
  50. * @see {@link retry}
  51. *
  52. * @param notifier Function that receives an Observable of notifications with which a
  53. * user can `complete` or `error`, aborting the retry.
  54. * @return A function that returns an Observable that mirrors the source
  55. * Observable with the exception of an `error`.
  56. * @deprecated Will be removed in v9 or v10, use {@link retry}'s `delay` option instead.
  57. * Will be removed in v9 or v10. Use {@link retry}'s {@link RetryConfig#delay delay} option instead.
  58. * Instead of `retryWhen(() => notify$)`, use: `retry({ delay: () => notify$ })`.
  59. */
  60. export declare function retryWhen<T>(notifier: (errors: Observable<any>) => ObservableInput<any>): MonoTypeOperatorFunction<T>;
  61. //# sourceMappingURL=retryWhen.d.ts.map