skipUntil.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. }
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var OuterSubscriber_1 = require("../OuterSubscriber");
  17. var InnerSubscriber_1 = require("../InnerSubscriber");
  18. var subscribeToResult_1 = require("../util/subscribeToResult");
  19. function skipUntil(notifier) {
  20. return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
  21. }
  22. exports.skipUntil = skipUntil;
  23. var SkipUntilOperator = (function () {
  24. function SkipUntilOperator(notifier) {
  25. this.notifier = notifier;
  26. }
  27. SkipUntilOperator.prototype.call = function (destination, source) {
  28. return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
  29. };
  30. return SkipUntilOperator;
  31. }());
  32. var SkipUntilSubscriber = (function (_super) {
  33. __extends(SkipUntilSubscriber, _super);
  34. function SkipUntilSubscriber(destination, notifier) {
  35. var _this = _super.call(this, destination) || this;
  36. _this.hasValue = false;
  37. var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(_this, undefined, undefined);
  38. _this.add(innerSubscriber);
  39. _this.innerSubscription = innerSubscriber;
  40. var innerSubscription = subscribeToResult_1.subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
  41. if (innerSubscription !== innerSubscriber) {
  42. _this.add(innerSubscription);
  43. _this.innerSubscription = innerSubscription;
  44. }
  45. return _this;
  46. }
  47. SkipUntilSubscriber.prototype._next = function (value) {
  48. if (this.hasValue) {
  49. _super.prototype._next.call(this, value);
  50. }
  51. };
  52. SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  53. this.hasValue = true;
  54. if (this.innerSubscription) {
  55. this.innerSubscription.unsubscribe();
  56. }
  57. };
  58. SkipUntilSubscriber.prototype.notifyComplete = function () {
  59. };
  60. return SkipUntilSubscriber;
  61. }(OuterSubscriber_1.OuterSubscriber));
  62. //# sourceMappingURL=skipUntil.js.map