2022-06-08 10:36:39 +00:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.retryWhen = void 0;
|
2023-02-08 12:35:10 +00:00
|
|
|
var innerFrom_1 = require("../observable/innerFrom");
|
2022-06-08 10:36:39 +00:00
|
|
|
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();
|
2023-02-08 12:35:10 +00:00
|
|
|
innerFrom_1.innerFrom(notifier(errors$)).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () {
|
2022-06-08 10:36:39 +00:00
|
|
|
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
|