rxjs
Version:
Reactive Extensions for modern JavaScript
17 lines • 586 B
JavaScript
import { operate } from '../util/lift';
import { OperatorSubscriber } from './OperatorSubscriber';
export function defaultIfEmpty(defaultValue) {
return operate(function (source, subscriber) {
var hasValue = false;
source.subscribe(new OperatorSubscriber(subscriber, function (value) {
hasValue = true;
subscriber.next(value);
}, function () {
if (!hasValue) {
subscriber.next(defaultValue);
}
subscriber.complete();
}));
});
}
//# sourceMappingURL=defaultIfEmpty.js.map