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