a zip code crypto-currency system good for red ONLY

takeUntil.js 2.9KB

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