Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm2015 / internal / operators / repeatWhen.js
1 import { Subject } from '../Subject';
2 import { OuterSubscriber } from '../OuterSubscriber';
3 import { subscribeToResult } from '../util/subscribeToResult';
4 export function repeatWhen(notifier) {
5     return (source) => source.lift(new RepeatWhenOperator(notifier));
6 }
7 class RepeatWhenOperator {
8     constructor(notifier) {
9         this.notifier = notifier;
10     }
11     call(subscriber, source) {
12         return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
13     }
14 }
15 class RepeatWhenSubscriber extends OuterSubscriber {
16     constructor(destination, notifier, source) {
17         super(destination);
18         this.notifier = notifier;
19         this.source = source;
20         this.sourceIsBeingSubscribedTo = true;
21     }
22     notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
23         this.sourceIsBeingSubscribedTo = true;
24         this.source.subscribe(this);
25     }
26     notifyComplete(innerSub) {
27         if (this.sourceIsBeingSubscribedTo === false) {
28             return super.complete();
29         }
30     }
31     complete() {
32         this.sourceIsBeingSubscribedTo = false;
33         if (!this.isStopped) {
34             if (!this.retries) {
35                 this.subscribeToRetries();
36             }
37             if (!this.retriesSubscription || this.retriesSubscription.closed) {
38                 return super.complete();
39             }
40             this._unsubscribeAndRecycle();
41             this.notifications.next();
42         }
43     }
44     _unsubscribe() {
45         const { notifications, retriesSubscription } = this;
46         if (notifications) {
47             notifications.unsubscribe();
48             this.notifications = null;
49         }
50         if (retriesSubscription) {
51             retriesSubscription.unsubscribe();
52             this.retriesSubscription = null;
53         }
54         this.retries = null;
55     }
56     _unsubscribeAndRecycle() {
57         const { _unsubscribe } = this;
58         this._unsubscribe = null;
59         super._unsubscribeAndRecycle();
60         this._unsubscribe = _unsubscribe;
61         return this;
62     }
63     subscribeToRetries() {
64         this.notifications = new Subject();
65         let retries;
66         try {
67             const { notifier } = this;
68             retries = notifier(this.notifications);
69         }
70         catch (e) {
71             return super.complete();
72         }
73         this.retries = retries;
74         this.retriesSubscription = subscribeToResult(this, retries);
75     }
76 }
77 //# sourceMappingURL=repeatWhen.js.map