skipUntil.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { OuterSubscriber } from '../OuterSubscriber';
  2. import { InnerSubscriber } from '../InnerSubscriber';
  3. import { subscribeToResult } from '../util/subscribeToResult';
  4. export function skipUntil(notifier) {
  5. return (source) => source.lift(new SkipUntilOperator(notifier));
  6. }
  7. class SkipUntilOperator {
  8. constructor(notifier) {
  9. this.notifier = notifier;
  10. }
  11. call(destination, source) {
  12. return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
  13. }
  14. }
  15. class SkipUntilSubscriber extends OuterSubscriber {
  16. constructor(destination, notifier) {
  17. super(destination);
  18. this.hasValue = false;
  19. const innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  20. this.add(innerSubscriber);
  21. this.innerSubscription = innerSubscriber;
  22. const innerSubscription = subscribeToResult(this, notifier, undefined, undefined, innerSubscriber);
  23. if (innerSubscription !== innerSubscriber) {
  24. this.add(innerSubscription);
  25. this.innerSubscription = innerSubscription;
  26. }
  27. }
  28. _next(value) {
  29. if (this.hasValue) {
  30. super._next(value);
  31. }
  32. }
  33. notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  34. this.hasValue = true;
  35. if (this.innerSubscription) {
  36. this.innerSubscription.unsubscribe();
  37. }
  38. }
  39. notifyComplete() {
  40. }
  41. }
  42. //# sourceMappingURL=skipUntil.js.map