Front end of the Slack clone application.

onErrorResumeNext.js 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use strict";
  2. var onErrorResumeNext_1 = require('../operators/onErrorResumeNext');
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * When any of the provided Observable emits an complete or error notification, it immediately subscribes to the next one
  6. * that was passed.
  7. *
  8. * <span class="informal">Execute series of Observables no matter what, even if it means swallowing errors.</span>
  9. *
  10. * <img src="./img/onErrorResumeNext.png" width="100%">
  11. *
  12. * `onErrorResumeNext` is an operator that accepts a series of Observables, provided either directly as
  13. * arguments or as an array. If no single Observable is provided, returned Observable will simply behave the same
  14. * as the source.
  15. *
  16. * `onErrorResumeNext` returns an Observable that starts by subscribing and re-emitting values from the source Observable.
  17. * When its stream of values ends - no matter if Observable completed or emitted an error - `onErrorResumeNext`
  18. * will subscribe to the first Observable that was passed as an argument to the method. It will start re-emitting
  19. * its values as well and - again - when that stream ends, `onErrorResumeNext` will proceed to subscribing yet another
  20. * Observable in provided series, no matter if previous Observable completed or ended with an error. This will
  21. * be happening until there is no more Observables left in the series, at which point returned Observable will
  22. * complete - even if the last subscribed stream ended with an error.
  23. *
  24. * `onErrorResumeNext` can be therefore thought of as version of {@link concat} operator, which is more permissive
  25. * when it comes to the errors emitted by its input Observables. While `concat` subscribes to the next Observable
  26. * in series only if previous one successfully completed, `onErrorResumeNext` subscribes even if it ended with
  27. * an error.
  28. *
  29. * Note that you do not get any access to errors emitted by the Observables. In particular do not
  30. * expect these errors to appear in error callback passed to {@link subscribe}. If you want to take
  31. * specific actions based on what error was emitted by an Observable, you should try out {@link catch} instead.
  32. *
  33. *
  34. * @example <caption>Subscribe to the next Observable after map fails</caption>
  35. * Rx.Observable.of(1, 2, 3, 0)
  36. * .map(x => {
  37. * if (x === 0) { throw Error(); }
  38. return 10 / x;
  39. * })
  40. * .onErrorResumeNext(Rx.Observable.of(1, 2, 3))
  41. * .subscribe(
  42. * val => console.log(val),
  43. * err => console.log(err), // Will never be called.
  44. * () => console.log('that\'s it!')
  45. * );
  46. *
  47. * // Logs:
  48. * // 10
  49. * // 5
  50. * // 3.3333333333333335
  51. * // 1
  52. * // 2
  53. * // 3
  54. * // "that's it!"
  55. *
  56. * @see {@link concat}
  57. * @see {@link catch}
  58. *
  59. * @param {...ObservableInput} observables Observables passed either directly or as an array.
  60. * @return {Observable} An Observable that emits values from source Observable, but - if it errors - subscribes
  61. * to the next passed Observable and so on, until it completes or runs out of Observables.
  62. * @method onErrorResumeNext
  63. * @owner Observable
  64. */
  65. function onErrorResumeNext() {
  66. var nextSources = [];
  67. for (var _i = 0; _i < arguments.length; _i++) {
  68. nextSources[_i - 0] = arguments[_i];
  69. }
  70. return onErrorResumeNext_1.onErrorResumeNext.apply(void 0, nextSources)(this);
  71. }
  72. exports.onErrorResumeNext = onErrorResumeNext;
  73. //# sourceMappingURL=onErrorResumeNext.js.map