Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ColdObservable.js 1.3KB

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