UI for Zipcoin Blue

ScalarObservable.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 ScalarObservable = (function (_super) {
  14. __extends(ScalarObservable, _super);
  15. function ScalarObservable(value, scheduler) {
  16. _super.call(this);
  17. this.value = value;
  18. this.scheduler = scheduler;
  19. this._isScalar = true;
  20. if (scheduler) {
  21. this._isScalar = false;
  22. }
  23. }
  24. ScalarObservable.create = function (value, scheduler) {
  25. return new ScalarObservable(value, scheduler);
  26. };
  27. ScalarObservable.dispatch = function (state) {
  28. var done = state.done, value = state.value, subscriber = state.subscriber;
  29. if (done) {
  30. subscriber.complete();
  31. return;
  32. }
  33. subscriber.next(value);
  34. if (subscriber.closed) {
  35. return;
  36. }
  37. state.done = true;
  38. this.schedule(state);
  39. };
  40. /** @deprecated internal use only */ ScalarObservable.prototype._subscribe = function (subscriber) {
  41. var value = this.value;
  42. var scheduler = this.scheduler;
  43. if (scheduler) {
  44. return scheduler.schedule(ScalarObservable.dispatch, 0, {
  45. done: false, value: value, subscriber: subscriber
  46. });
  47. }
  48. else {
  49. subscriber.next(value);
  50. if (!subscriber.closed) {
  51. subscriber.complete();
  52. }
  53. }
  54. };
  55. return ScalarObservable;
  56. }(Observable_1.Observable));
  57. exports.ScalarObservable = ScalarObservable;
  58. //# sourceMappingURL=ScalarObservable.js.map