a zip code crypto-currency system good for red ONLY

defaultIfEmpty.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. var defaultIfEmpty_1 = require('../operators/defaultIfEmpty');
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * Emits a given value if the source Observable completes without emitting any
  6. * `next` value, otherwise mirrors the source Observable.
  7. *
  8. * <span class="informal">If the source Observable turns out to be empty, then
  9. * this operator will emit a default value.</span>
  10. *
  11. * <img src="./img/defaultIfEmpty.png" width="100%">
  12. *
  13. * `defaultIfEmpty` emits the values emitted by the source Observable or a
  14. * specified default value if the source Observable is empty (completes without
  15. * having emitted any `next` value).
  16. *
  17. * @example <caption>If no clicks happen in 5 seconds, then emit "no clicks"</caption>
  18. * var clicks = Rx.Observable.fromEvent(document, 'click');
  19. * var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000));
  20. * var result = clicksBeforeFive.defaultIfEmpty('no clicks');
  21. * result.subscribe(x => console.log(x));
  22. *
  23. * @see {@link empty}
  24. * @see {@link last}
  25. *
  26. * @param {any} [defaultValue=null] The default value used if the source
  27. * Observable is empty.
  28. * @return {Observable} An Observable that emits either the specified
  29. * `defaultValue` if the source Observable emits no items, or the values emitted
  30. * by the source Observable.
  31. * @method defaultIfEmpty
  32. * @owner Observable
  33. */
  34. function defaultIfEmpty(defaultValue) {
  35. if (defaultValue === void 0) { defaultValue = null; }
  36. return defaultIfEmpty_1.defaultIfEmpty(defaultValue)(this);
  37. }
  38. exports.defaultIfEmpty = defaultIfEmpty;
  39. //# sourceMappingURL=defaultIfEmpty.js.map