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