source: trip-planner-front/node_modules/rxjs/_esm2015/internal/operators/retryWhen.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1import { Subject } from '../Subject';
2import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
3export function retryWhen(notifier) {
4 return (source) => source.lift(new RetryWhenOperator(notifier, source));
5}
6class 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}
15class 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
Note: See TracBrowser for help on using the repository browser.