a zip code crypto-currency system good for red ONLY

catch.d.ts 2.0KB

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