a zip code crypto-currency system good for red ONLY

ColdObservable.js 1.3KB

12345678910111213141516171819202122232425262728293031323334
  1. import { Observable } from '../Observable';
  2. import { Subscription } from '../Subscription';
  3. import { SubscriptionLoggable } from './SubscriptionLoggable';
  4. import { applyMixins } from '../util/applyMixins';
  5. /**
  6. * We need this JSDoc comment for affecting ESDoc.
  7. * @ignore
  8. * @extends {Ignored}
  9. */
  10. export class ColdObservable extends Observable {
  11. constructor(messages, scheduler) {
  12. super(function (subscriber) {
  13. const observable = this;
  14. const index = observable.logSubscribedFrame();
  15. subscriber.add(new Subscription(() => {
  16. observable.logUnsubscribedFrame(index);
  17. }));
  18. observable.scheduleMessages(subscriber);
  19. return subscriber;
  20. });
  21. this.messages = messages;
  22. this.subscriptions = [];
  23. this.scheduler = scheduler;
  24. }
  25. scheduleMessages(subscriber) {
  26. const messagesLength = this.messages.length;
  27. for (let i = 0; i < messagesLength; i++) {
  28. const message = this.messages[i];
  29. subscriber.add(this.scheduler.schedule(({ message, subscriber }) => { message.notification.observe(subscriber); }, message.frame, { message, subscriber }));
  30. }
  31. }
  32. }
  33. applyMixins(ColdObservable, [SubscriptionLoggable]);
  34. //# sourceMappingURL=ColdObservable.js.map