UI for Zipcoin Blue

ErrorObservable.js 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 ErrorObservable = (function (_super) {
  14. __extends(ErrorObservable, _super);
  15. function ErrorObservable(error, scheduler) {
  16. _super.call(this);
  17. this.error = error;
  18. this.scheduler = scheduler;
  19. }
  20. /**
  21. * Creates an Observable that emits no items to the Observer and immediately
  22. * emits an error notification.
  23. *
  24. * <span class="informal">Just emits 'error', and nothing else.
  25. * </span>
  26. *
  27. * <img src="./img/throw.png" width="100%">
  28. *
  29. * This static operator is useful for creating a simple Observable that only
  30. * emits the error notification. It can be used for composing with other
  31. * Observables, such as in a {@link mergeMap}.
  32. *
  33. * @example <caption>Emit the number 7, then emit an error.</caption>
  34. * var result = Rx.Observable.throw(new Error('oops!')).startWith(7);
  35. * result.subscribe(x => console.log(x), e => console.error(e));
  36. *
  37. * @example <caption>Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for 13</caption>
  38. * var interval = Rx.Observable.interval(1000);
  39. * var result = interval.mergeMap(x =>
  40. * x === 13 ?
  41. * Rx.Observable.throw('Thirteens are bad') :
  42. * Rx.Observable.of('a', 'b', 'c')
  43. * );
  44. * result.subscribe(x => console.log(x), e => console.error(e));
  45. *
  46. * @see {@link create}
  47. * @see {@link empty}
  48. * @see {@link never}
  49. * @see {@link of}
  50. *
  51. * @param {any} error The particular Error to pass to the error notification.
  52. * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
  53. * the emission of the error notification.
  54. * @return {Observable} An error Observable: emits only the error notification
  55. * using the given error argument.
  56. * @static true
  57. * @name throw
  58. * @owner Observable
  59. */
  60. ErrorObservable.create = function (error, scheduler) {
  61. return new ErrorObservable(error, scheduler);
  62. };
  63. ErrorObservable.dispatch = function (arg) {
  64. var error = arg.error, subscriber = arg.subscriber;
  65. subscriber.error(error);
  66. };
  67. /** @deprecated internal use only */ ErrorObservable.prototype._subscribe = function (subscriber) {
  68. var error = this.error;
  69. var scheduler = this.scheduler;
  70. subscriber.syncErrorThrowable = true;
  71. if (scheduler) {
  72. return scheduler.schedule(ErrorObservable.dispatch, 0, {
  73. error: error, subscriber: subscriber
  74. });
  75. }
  76. else {
  77. subscriber.error(error);
  78. }
  79. };
  80. return ErrorObservable;
  81. }(Observable_1.Observable));
  82. exports.ErrorObservable = ErrorObservable;
  83. //# sourceMappingURL=ErrorObservable.js.map