hugoWebsite/node_modules/rxjs/dist/cjs/internal/operators/retryWhen.js

35 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-10-29 00:20:35 +02:00
"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