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 { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
|
---|
2 | export function exhaust() {
|
---|
3 | return (source) => source.lift(new SwitchFirstOperator());
|
---|
4 | }
|
---|
5 | class SwitchFirstOperator {
|
---|
6 | call(subscriber, source) {
|
---|
7 | return source.subscribe(new SwitchFirstSubscriber(subscriber));
|
---|
8 | }
|
---|
9 | }
|
---|
10 | class SwitchFirstSubscriber extends SimpleOuterSubscriber {
|
---|
11 | constructor(destination) {
|
---|
12 | super(destination);
|
---|
13 | this.hasCompleted = false;
|
---|
14 | this.hasSubscription = false;
|
---|
15 | }
|
---|
16 | _next(value) {
|
---|
17 | if (!this.hasSubscription) {
|
---|
18 | this.hasSubscription = true;
|
---|
19 | this.add(innerSubscribe(value, new SimpleInnerSubscriber(this)));
|
---|
20 | }
|
---|
21 | }
|
---|
22 | _complete() {
|
---|
23 | this.hasCompleted = true;
|
---|
24 | if (!this.hasSubscription) {
|
---|
25 | this.destination.complete();
|
---|
26 | }
|
---|
27 | }
|
---|
28 | notifyComplete() {
|
---|
29 | this.hasSubscription = false;
|
---|
30 | if (this.hasCompleted) {
|
---|
31 | this.destination.complete();
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
35 | //# sourceMappingURL=exhaust.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.