Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

takeUntil.js 1.0KB

12345678910111213141516171819202122232425262728293031
  1. import { innerSubscribe, SimpleInnerSubscriber, SimpleOuterSubscriber } from '../innerSubscribe';
  2. export function takeUntil(notifier) {
  3. return (source) => source.lift(new TakeUntilOperator(notifier));
  4. }
  5. class TakeUntilOperator {
  6. constructor(notifier) {
  7. this.notifier = notifier;
  8. }
  9. call(subscriber, source) {
  10. const takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
  11. const notifierSubscription = innerSubscribe(this.notifier, new SimpleInnerSubscriber(takeUntilSubscriber));
  12. if (notifierSubscription && !takeUntilSubscriber.seenValue) {
  13. takeUntilSubscriber.add(notifierSubscription);
  14. return source.subscribe(takeUntilSubscriber);
  15. }
  16. return takeUntilSubscriber;
  17. }
  18. }
  19. class TakeUntilSubscriber extends SimpleOuterSubscriber {
  20. constructor(destination) {
  21. super(destination);
  22. this.seenValue = false;
  23. }
  24. notifyNext() {
  25. this.seenValue = true;
  26. this.complete();
  27. }
  28. notifyComplete() {
  29. }
  30. }
  31. //# sourceMappingURL=takeUntil.js.map