28 lines
No EOL
1.4 KiB
JavaScript
28 lines
No EOL
1.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.switchMap = void 0;
|
|
var innerFrom_1 = require("../observable/innerFrom");
|
|
var lift_1 = require("../util/lift");
|
|
var OperatorSubscriber_1 = require("./OperatorSubscriber");
|
|
function switchMap(project, resultSelector) {
|
|
return lift_1.operate(function (source, subscriber) {
|
|
var innerSubscriber = null;
|
|
var index = 0;
|
|
var isComplete = false;
|
|
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
|
|
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
var innerIndex = 0;
|
|
var outerIndex = index++;
|
|
innerFrom_1.innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
innerSubscriber = null;
|
|
checkComplete();
|
|
})));
|
|
}, function () {
|
|
isComplete = true;
|
|
checkComplete();
|
|
}));
|
|
});
|
|
}
|
|
exports.switchMap = switchMap;
|
|
//# sourceMappingURL=switchMap.js.map
|