This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/rxjs/_esm2015/internal/operators/retryWhen.js
2019-08-11 20:48:02 +02:00

69 lines
No EOL
2.2 KiB
JavaScript

import { Subject } from '../Subject';
import { OuterSubscriber } from '../OuterSubscriber';
import { subscribeToResult } from '../util/subscribeToResult';
export function retryWhen(notifier) {
return (source) => source.lift(new RetryWhenOperator(notifier, source));
}
class RetryWhenOperator {
constructor(notifier, source) {
this.notifier = notifier;
this.source = source;
}
call(subscriber, source) {
return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
}
}
class RetryWhenSubscriber extends OuterSubscriber {
constructor(destination, notifier, source) {
super(destination);
this.notifier = notifier;
this.source = source;
}
error(err) {
if (!this.isStopped) {
let errors = this.errors;
let retries = this.retries;
let retriesSubscription = this.retriesSubscription;
if (!retries) {
errors = new Subject();
try {
const { notifier } = this;
retries = notifier(errors);
}
catch (e) {
return super.error(e);
}
retriesSubscription = subscribeToResult(this, retries);
}
else {
this.errors = null;
this.retriesSubscription = null;
}
this._unsubscribeAndRecycle();
this.errors = errors;
this.retries = retries;
this.retriesSubscription = retriesSubscription;
errors.next(err);
}
}
_unsubscribe() {
const { errors, retriesSubscription } = this;
if (errors) {
errors.unsubscribe();
this.errors = null;
}
if (retriesSubscription) {
retriesSubscription.unsubscribe();
this.retriesSubscription = null;
}
this.retries = null;
}
notifyNext(outerValue, innerValue, outerIndex, innerIndex, innerSub) {
const { _unsubscribe } = this;
this._unsubscribe = null;
this._unsubscribeAndRecycle();
this._unsubscribe = _unsubscribe;
this.source.subscribe(this);
}
}
//# sourceMappingURL=retryWhen.js.map