NeverObservable.js 2.2KB

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