HotObservable.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /** PURE_IMPORTS_START .._Subject,.._Subscription,._SubscriptionLoggable,.._util_applyMixins 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 { Subject } from '../Subject';
  10. import { Subscription } from '../Subscription';
  11. import { SubscriptionLoggable } from './SubscriptionLoggable';
  12. import { applyMixins } from '../util/applyMixins';
  13. /**
  14. * We need this JSDoc comment for affecting ESDoc.
  15. * @ignore
  16. * @extends {Ignored}
  17. */
  18. export var HotObservable = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  19. __extends(HotObservable, _super);
  20. function HotObservable(messages, scheduler) {
  21. _super.call(this);
  22. this.messages = messages;
  23. this.subscriptions = [];
  24. this.scheduler = scheduler;
  25. }
  26. /** @deprecated internal use only */ HotObservable.prototype._subscribe = function (subscriber) {
  27. var subject = this;
  28. var index = subject.logSubscribedFrame();
  29. subscriber.add(new Subscription(function () {
  30. subject.logUnsubscribedFrame(index);
  31. }));
  32. return _super.prototype._subscribe.call(this, subscriber);
  33. };
  34. HotObservable.prototype.setup = function () {
  35. var subject = this;
  36. var messagesLength = subject.messages.length;
  37. /* tslint:disable:no-var-keyword */
  38. for (var i = 0; i < messagesLength; i++) {
  39. (function () {
  40. var message = subject.messages[i];
  41. /* tslint:enable */
  42. subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
  43. })();
  44. }
  45. };
  46. return HotObservable;
  47. }(Subject));
  48. /*@__PURE__*/ applyMixins(HotObservable, [SubscriptionLoggable]);
  49. //# sourceMappingURL=HotObservable.js.map