UNPKG

rxjs

Version:

Reactive Extensions for modern JavaScript

21 lines 757 B
"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(new OperatorSubscriber_1.OperatorSubscriber(subscriber, function (value) { hasValue = true; subscriber.next(value); }, function () { if (!hasValue) { subscriber.next(defaultValue); } subscriber.complete(); })); }); } exports.defaultIfEmpty = defaultIfEmpty; //# sourceMappingURL=defaultIfEmpty.js.map