a zip code crypto-currency system good for red ONLY

defaultIfEmpty.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /** PURE_IMPORTS_START .._operators_defaultIfEmpty PURE_IMPORTS_END */
  2. import { defaultIfEmpty as higherOrder } from '../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. export function defaultIfEmpty(defaultValue) {
  35. if (defaultValue === void 0) {
  36. defaultValue = null;
  37. }
  38. return higherOrder(defaultValue)(this);
  39. }
  40. //# sourceMappingURL=defaultIfEmpty.js.map