wishthis/node_modules/rxjs/dist/cjs/internal/operators/defaultIfEmpty.js
2022-06-08 12:36:39 +02:00

21 lines
No EOL
759 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultIfEmpty = void 0;
var lift_1 = require("../util/lift");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function defaultIfEmpty(defaultValue) {
return lift_1.operate(function (source, subscriber) {
var hasValue = false;
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
hasValue = true;
subscriber.next(value);
}, function () {
if (!hasValue) {
subscriber.next(defaultValue);
}
subscriber.complete();
}));
});
}
exports.defaultIfEmpty = defaultIfEmpty;
//# sourceMappingURL=defaultIfEmpty.js.map