a zip code crypto-currency system good for red ONLY

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /** PURE_IMPORTS_START .._Subscriber PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Subscriber } from '../Subscriber';
  10. /**
  11. * Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable
  12. * calls `error`, this method will resubscribe to the source Observable for a maximum of `count` resubscriptions (given
  13. * as a number parameter) rather than propagating the `error` call.
  14. *
  15. * <img src="./img/retry.png" width="100%">
  16. *
  17. * Any and all items emitted by the source Observable will be emitted by the resulting Observable, even those emitted
  18. * during failed subscriptions. For example, if an Observable fails at first but emits [1, 2] then succeeds the second
  19. * time and emits: [1, 2, 3, 4, 5] then the complete stream of emissions and notifications
  20. * would be: [1, 2, 1, 2, 3, 4, 5, `complete`].
  21. * @param {number} count - Number of retry attempts before failing.
  22. * @return {Observable} The source Observable modified with the retry logic.
  23. * @method retry
  24. * @owner Observable
  25. */
  26. export function retry(count) {
  27. if (count === void 0) {
  28. count = -1;
  29. }
  30. return function (source) { return source.lift(new RetryOperator(count, source)); };
  31. }
  32. var RetryOperator = /*@__PURE__*/ (/*@__PURE__*/ function () {
  33. function RetryOperator(count, source) {
  34. this.count = count;
  35. this.source = source;
  36. }
  37. RetryOperator.prototype.call = function (subscriber, source) {
  38. return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
  39. };
  40. return RetryOperator;
  41. }());
  42. /**
  43. * We need this JSDoc comment for affecting ESDoc.
  44. * @ignore
  45. * @extends {Ignored}
  46. */
  47. var RetrySubscriber = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  48. __extends(RetrySubscriber, _super);
  49. function RetrySubscriber(destination, count, source) {
  50. _super.call(this, destination);
  51. this.count = count;
  52. this.source = source;
  53. }
  54. RetrySubscriber.prototype.error = function (err) {
  55. if (!this.isStopped) {
  56. var _a = this, source = _a.source, count = _a.count;
  57. if (count === 0) {
  58. return _super.prototype.error.call(this, err);
  59. }
  60. else if (count > -1) {
  61. this.count = count - 1;
  62. }
  63. source.subscribe(this._unsubscribeAndRecycle());
  64. }
  65. };
  66. return RetrySubscriber;
  67. }(Subscriber));
  68. //# sourceMappingURL=retry.js.map