wishthis/node_modules/rxjs/dist/cjs/internal/operators/repeatWhen.js

50 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-06-08 10:36:39 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.repeatWhen = 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 repeatWhen(notifier) {
return lift_1.operate(function (source, subscriber) {
var innerSub;
var syncResub = false;
var completions$;
var isNotifierComplete = false;
var isMainComplete = false;
var checkComplete = function () { return isMainComplete && isNotifierComplete && (subscriber.complete(), true); };
var getCompletionSubject = function () {
if (!completions$) {
completions$ = new Subject_1.Subject();
2023-02-08 12:35:10 +00:00
innerFrom_1.innerFrom(notifier(completions$)).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () {
2022-06-08 10:36:39 +00:00
if (innerSub) {
subscribeForRepeatWhen();
}
else {
syncResub = true;
}
}, function () {
isNotifierComplete = true;
checkComplete();
}));
}
return completions$;
};
var subscribeForRepeatWhen = function () {
isMainComplete = false;
innerSub = source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, undefined, function () {
isMainComplete = true;
!checkComplete() && getCompletionSubject().next();
}));
if (syncResub) {
innerSub.unsubscribe();
innerSub = null;
syncResub = false;
subscribeForRepeatWhen();
}
};
subscribeForRepeatWhen();
});
}
exports.repeatWhen = repeatWhen;
//# sourceMappingURL=repeatWhen.js.map