Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

HotObservable.js 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. import { Subject } from '../Subject';
  2. import { Subscription } from '../Subscription';
  3. import { SubscriptionLoggable } from './SubscriptionLoggable';
  4. import { applyMixins } from '../util/applyMixins';
  5. export class HotObservable extends Subject {
  6. constructor(messages, scheduler) {
  7. super();
  8. this.messages = messages;
  9. this.subscriptions = [];
  10. this.scheduler = scheduler;
  11. }
  12. _subscribe(subscriber) {
  13. const subject = this;
  14. const index = subject.logSubscribedFrame();
  15. const subscription = new Subscription();
  16. subscription.add(new Subscription(() => {
  17. subject.logUnsubscribedFrame(index);
  18. }));
  19. subscription.add(super._subscribe(subscriber));
  20. return subscription;
  21. }
  22. setup() {
  23. const subject = this;
  24. const messagesLength = subject.messages.length;
  25. for (var i = 0; i < messagesLength; i++) {
  26. (() => {
  27. var message = subject.messages[i];
  28. subject.scheduler.schedule(() => { message.notification.observe(subject); }, message.frame);
  29. })();
  30. }
  31. }
  32. }
  33. applyMixins(HotObservable, [SubscriptionLoggable]);
  34. //# sourceMappingURL=HotObservable.js.map