Front end of the Slack clone application.

EmptyObservable.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var Observable_1 = require('../Observable');
  8. /**
  9. * We need this JSDoc comment for affecting ESDoc.
  10. * @extends {Ignored}
  11. * @hide true
  12. */
  13. var EmptyObservable = (function (_super) {
  14. __extends(EmptyObservable, _super);
  15. function EmptyObservable(scheduler) {
  16. _super.call(this);
  17. this.scheduler = scheduler;
  18. }
  19. /**
  20. * Creates an Observable that emits no items to the Observer and immediately
  21. * emits a complete notification.
  22. *
  23. * <span class="informal">Just emits 'complete', and nothing else.
  24. * </span>
  25. *
  26. * <img src="./img/empty.png" width="100%">
  27. *
  28. * This static operator is useful for creating a simple Observable that only
  29. * emits the complete notification. It can be used for composing with other
  30. * Observables, such as in a {@link mergeMap}.
  31. *
  32. * @example <caption>Emit the number 7, then complete.</caption>
  33. * var result = Rx.Observable.empty().startWith(7);
  34. * result.subscribe(x => console.log(x));
  35. *
  36. * @example <caption>Map and flatten only odd numbers to the sequence 'a', 'b', 'c'</caption>
  37. * var interval = Rx.Observable.interval(1000);
  38. * var result = interval.mergeMap(x =>
  39. * x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
  40. * );
  41. * result.subscribe(x => console.log(x));
  42. *
  43. * // Results in the following to the console:
  44. * // x is equal to the count on the interval eg(0,1,2,3,...)
  45. * // x will occur every 1000ms
  46. * // if x % 2 is equal to 1 print abc
  47. * // if x % 2 is not equal to 1 nothing will be output
  48. *
  49. * @see {@link create}
  50. * @see {@link never}
  51. * @see {@link of}
  52. * @see {@link throw}
  53. *
  54. * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
  55. * the emission of the complete notification.
  56. * @return {Observable} An "empty" Observable: emits only the complete
  57. * notification.
  58. * @static true
  59. * @name empty
  60. * @owner Observable
  61. */
  62. EmptyObservable.create = function (scheduler) {
  63. return new EmptyObservable(scheduler);
  64. };
  65. EmptyObservable.dispatch = function (arg) {
  66. var subscriber = arg.subscriber;
  67. subscriber.complete();
  68. };
  69. /** @deprecated internal use only */ EmptyObservable.prototype._subscribe = function (subscriber) {
  70. var scheduler = this.scheduler;
  71. if (scheduler) {
  72. return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber });
  73. }
  74. else {
  75. subscriber.complete();
  76. }
  77. };
  78. return EmptyObservable;
  79. }(Observable_1.Observable));
  80. exports.EmptyObservable = EmptyObservable;
  81. //# sourceMappingURL=EmptyObservable.js.map