HotObservable.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.HotObservable = void 0;
  19. var Subject_1 = require("../Subject");
  20. var Subscription_1 = require("../Subscription");
  21. var SubscriptionLoggable_1 = require("./SubscriptionLoggable");
  22. var applyMixins_1 = require("../util/applyMixins");
  23. var Notification_1 = require("../Notification");
  24. var HotObservable = (function (_super) {
  25. __extends(HotObservable, _super);
  26. function HotObservable(messages, scheduler) {
  27. var _this = _super.call(this) || this;
  28. _this.messages = messages;
  29. _this.subscriptions = [];
  30. _this.scheduler = scheduler;
  31. return _this;
  32. }
  33. HotObservable.prototype._subscribe = function (subscriber) {
  34. var subject = this;
  35. var index = subject.logSubscribedFrame();
  36. var subscription = new Subscription_1.Subscription();
  37. subscription.add(new Subscription_1.Subscription(function () {
  38. subject.logUnsubscribedFrame(index);
  39. }));
  40. subscription.add(_super.prototype._subscribe.call(this, subscriber));
  41. return subscription;
  42. };
  43. HotObservable.prototype.setup = function () {
  44. var subject = this;
  45. var messagesLength = subject.messages.length;
  46. var _loop_1 = function (i) {
  47. (function () {
  48. var _a = subject.messages[i], notification = _a.notification, frame = _a.frame;
  49. subject.scheduler.schedule(function () {
  50. Notification_1.observeNotification(notification, subject);
  51. }, frame);
  52. })();
  53. };
  54. for (var i = 0; i < messagesLength; i++) {
  55. _loop_1(i);
  56. }
  57. };
  58. return HotObservable;
  59. }(Subject_1.Subject));
  60. exports.HotObservable = HotObservable;
  61. applyMixins_1.applyMixins(HotObservable, [SubscriptionLoggable_1.SubscriptionLoggable]);
  62. //# sourceMappingURL=HotObservable.js.map