Front end of the Slack clone application.

defaultIfEmpty.js 1.5KB

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