Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
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 |
---|
Note:
See
TracBrowser
for help on using the repository browser.