defaultIfEmpty.js 759 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.defaultIfEmpty = void 0;
  4. var lift_1 = require("../util/lift");
  5. var OperatorSubscriber_1 = require("./OperatorSubscriber");
  6. function defaultIfEmpty(defaultValue) {
  7. return lift_1.operate(function (source, subscriber) {
  8. var hasValue = false;
  9. source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
  10. hasValue = true;
  11. subscriber.next(value);
  12. }, function () {
  13. if (!hasValue) {
  14. subscriber.next(defaultValue);
  15. }
  16. subscriber.complete();
  17. }));
  18. });
  19. }
  20. exports.defaultIfEmpty = defaultIfEmpty;
  21. //# sourceMappingURL=defaultIfEmpty.js.map