ColdObservable.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /** PURE_IMPORTS_START .._Observable,.._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 { Observable } from '../Observable';
  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 ColdObservable = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  19. __extends(ColdObservable, _super);
  20. function ColdObservable(messages, scheduler) {
  21. _super.call(this, function (subscriber) {
  22. var observable = this;
  23. var index = observable.logSubscribedFrame();
  24. subscriber.add(new Subscription(function () {
  25. observable.logUnsubscribedFrame(index);
  26. }));
  27. observable.scheduleMessages(subscriber);
  28. return subscriber;
  29. });
  30. this.messages = messages;
  31. this.subscriptions = [];
  32. this.scheduler = scheduler;
  33. }
  34. ColdObservable.prototype.scheduleMessages = function (subscriber) {
  35. var messagesLength = this.messages.length;
  36. for (var i = 0; i < messagesLength; i++) {
  37. var message = this.messages[i];
  38. subscriber.add(this.scheduler.schedule(function (_a) {
  39. var message = _a.message, subscriber = _a.subscriber;
  40. message.notification.observe(subscriber);
  41. }, message.frame, { message: message, subscriber: subscriber }));
  42. }
  43. };
  44. return ColdObservable;
  45. }(Observable));
  46. /*@__PURE__*/ applyMixins(ColdObservable, [SubscriptionLoggable]);
  47. //# sourceMappingURL=ColdObservable.js.map