a zip code crypto-currency system good for red ONLY

takeUntil.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var OuterSubscriber_1 = require('../OuterSubscriber');
  8. var subscribeToResult_1 = require('../util/subscribeToResult');
  9. /**
  10. * Emits the values emitted by the source Observable until a `notifier`
  11. * Observable emits a value.
  12. *
  13. * <span class="informal">Lets values pass until a second Observable,
  14. * `notifier`, emits something. Then, it completes.</span>
  15. *
  16. * <img src="./img/takeUntil.png" width="100%">
  17. *
  18. * `takeUntil` subscribes and begins mirroring the source Observable. It also
  19. * monitors a second Observable, `notifier` that you provide. If the `notifier`
  20. * emits a value or a complete notification, the output Observable stops
  21. * mirroring the source Observable and completes.
  22. *
  23. * @example <caption>Tick every second until the first click happens</caption>
  24. * var interval = Rx.Observable.interval(1000);
  25. * var clicks = Rx.Observable.fromEvent(document, 'click');
  26. * var result = interval.takeUntil(clicks);
  27. * result.subscribe(x => console.log(x));
  28. *
  29. * @see {@link take}
  30. * @see {@link takeLast}
  31. * @see {@link takeWhile}
  32. * @see {@link skip}
  33. *
  34. * @param {Observable} notifier The Observable whose first emitted value will
  35. * cause the output Observable of `takeUntil` to stop emitting values from the
  36. * source Observable.
  37. * @return {Observable<T>} An Observable that emits the values from the source
  38. * Observable until such time as `notifier` emits its first value.
  39. * @method takeUntil
  40. * @owner Observable
  41. */
  42. function takeUntil(notifier) {
  43. return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
  44. }
  45. exports.takeUntil = takeUntil;
  46. var TakeUntilOperator = (function () {
  47. function TakeUntilOperator(notifier) {
  48. this.notifier = notifier;
  49. }
  50. TakeUntilOperator.prototype.call = function (subscriber, source) {
  51. return source.subscribe(new TakeUntilSubscriber(subscriber, this.notifier));
  52. };
  53. return TakeUntilOperator;
  54. }());
  55. /**
  56. * We need this JSDoc comment for affecting ESDoc.
  57. * @ignore
  58. * @extends {Ignored}
  59. */
  60. var TakeUntilSubscriber = (function (_super) {
  61. __extends(TakeUntilSubscriber, _super);
  62. function TakeUntilSubscriber(destination, notifier) {
  63. _super.call(this, destination);
  64. this.notifier = notifier;
  65. this.add(subscribeToResult_1.subscribeToResult(this, notifier));
  66. }
  67. TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  68. this.complete();
  69. };
  70. TakeUntilSubscriber.prototype.notifyComplete = function () {
  71. // noop
  72. };
  73. return TakeUntilSubscriber;
  74. }(OuterSubscriber_1.OuterSubscriber));
  75. //# sourceMappingURL=takeUntil.js.map