a zip code crypto-currency system good for red ONLY

catchError.d.ts 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Observable, ObservableInput } from '../Observable';
  2. import { OperatorFunction } from '../interfaces';
  3. /**
  4. * Catches errors on the observable to be handled by returning a new observable or throwing an error.
  5. *
  6. * <img src="./img/catch.png" width="100%">
  7. *
  8. * @example <caption>Continues with a different Observable when there's an error</caption>
  9. *
  10. * Observable.of(1, 2, 3, 4, 5)
  11. * .map(n => {
  12. * if (n == 4) {
  13. * throw 'four!';
  14. * }
  15. * return n;
  16. * })
  17. * .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
  18. * .subscribe(x => console.log(x));
  19. * // 1, 2, 3, I, II, III, IV, V
  20. *
  21. * @example <caption>Retries the caught source Observable again in case of error, similar to retry() operator</caption>
  22. *
  23. * Observable.of(1, 2, 3, 4, 5)
  24. * .map(n => {
  25. * if (n === 4) {
  26. * throw 'four!';
  27. * }
  28. * return n;
  29. * })
  30. * .catch((err, caught) => caught)
  31. * .take(30)
  32. * .subscribe(x => console.log(x));
  33. * // 1, 2, 3, 1, 2, 3, ...
  34. *
  35. * @example <caption>Throws a new error when the source Observable throws an error</caption>
  36. *
  37. * Observable.of(1, 2, 3, 4, 5)
  38. * .map(n => {
  39. * if (n == 4) {
  40. * throw 'four!';
  41. * }
  42. * return n;
  43. * })
  44. * .catch(err => {
  45. * throw 'error in source. Details: ' + err;
  46. * })
  47. * .subscribe(
  48. * x => console.log(x),
  49. * err => console.log(err)
  50. * );
  51. * // 1, 2, 3, error in source. Details: four!
  52. *
  53. * @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
  54. * is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
  55. * is returned by the `selector` will be used to continue the observable chain.
  56. * @return {Observable} An observable that originates from either the source or the observable returned by the
  57. * catch `selector` function.
  58. * @name catchError
  59. */
  60. export declare function catchError<T, R>(selector: (err: any, caught: Observable<T>) => ObservableInput<R>): OperatorFunction<T, T | R>;