NeverObservable.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. var noop_1 = require('../util/noop');
  9. /**
  10. * We need this JSDoc comment for affecting ESDoc.
  11. * @extends {Ignored}
  12. * @hide true
  13. */
  14. var NeverObservable = (function (_super) {
  15. __extends(NeverObservable, _super);
  16. function NeverObservable() {
  17. _super.call(this);
  18. }
  19. /**
  20. * Creates an Observable that emits no items to the Observer.
  21. *
  22. * <span class="informal">An Observable that never emits anything.</span>
  23. *
  24. * <img src="./img/never.png" width="100%">
  25. *
  26. * This static operator is useful for creating a simple Observable that emits
  27. * neither values nor errors nor the completion notification. It can be used
  28. * for testing purposes or for composing with other Observables. Please note
  29. * that by never emitting a complete notification, this Observable keeps the
  30. * subscription from being disposed automatically. Subscriptions need to be
  31. * manually disposed.
  32. *
  33. * @example <caption>Emit the number 7, then never emit anything else (not even complete).</caption>
  34. * function info() {
  35. * console.log('Will not be called');
  36. * }
  37. * var result = Rx.Observable.never().startWith(7);
  38. * result.subscribe(x => console.log(x), info, info);
  39. *
  40. * @see {@link create}
  41. * @see {@link empty}
  42. * @see {@link of}
  43. * @see {@link throw}
  44. *
  45. * @return {Observable} A "never" Observable: never emits anything.
  46. * @static true
  47. * @name never
  48. * @owner Observable
  49. */
  50. NeverObservable.create = function () {
  51. return new NeverObservable();
  52. };
  53. /** @deprecated internal use only */ NeverObservable.prototype._subscribe = function (subscriber) {
  54. noop_1.noop();
  55. };
  56. return NeverObservable;
  57. }(Observable_1.Observable));
  58. exports.NeverObservable = NeverObservable;
  59. //# sourceMappingURL=NeverObservable.js.map