wishthis/node_modules/rxjs/dist/cjs/internal/operators/retryWhen.js
2022-04-07 09:06:43 +02:00

35 lines
No EOL
1.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.retryWhen = void 0;
var Subject_1 = require("../Subject");
var lift_1 = require("../util/lift");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function retryWhen(notifier) {
return lift_1.operate(function (source, subscriber) {
var innerSub;
var syncResub = false;
var errors$;
var subscribeForRetryWhen = function () {
innerSub = source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
if (!errors$) {
errors$ = new Subject_1.Subject();
notifier(errors$).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () {
return innerSub ? subscribeForRetryWhen() : (syncResub = true);
}));
}
if (errors$) {
errors$.next(err);
}
}));
if (syncResub) {
innerSub.unsubscribe();
innerSub = null;
syncResub = false;
subscribeForRetryWhen();
}
};
subscribeForRetryWhen();
});
}
exports.retryWhen = retryWhen;
//# sourceMappingURL=retryWhen.js.map