2022-01-21 08:28:41 +00:00
|
|
|
import { Subject } from '../Subject';
|
|
|
|
import { Subscription } from '../Subscription';
|
|
|
|
import { SubscriptionLoggable } from './SubscriptionLoggable';
|
|
|
|
import { applyMixins } from '../util/applyMixins';
|
2022-04-07 07:06:43 +00:00
|
|
|
import { observeNotification } from '../Notification';
|
2022-01-21 08:28:41 +00:00
|
|
|
export class HotObservable extends Subject {
|
|
|
|
constructor(messages, scheduler) {
|
|
|
|
super();
|
|
|
|
this.messages = messages;
|
|
|
|
this.subscriptions = [];
|
|
|
|
this.scheduler = scheduler;
|
|
|
|
}
|
|
|
|
_subscribe(subscriber) {
|
|
|
|
const subject = this;
|
|
|
|
const index = subject.logSubscribedFrame();
|
|
|
|
const subscription = new Subscription();
|
|
|
|
subscription.add(new Subscription(() => {
|
|
|
|
subject.logUnsubscribedFrame(index);
|
|
|
|
}));
|
|
|
|
subscription.add(super._subscribe(subscriber));
|
|
|
|
return subscription;
|
|
|
|
}
|
|
|
|
setup() {
|
|
|
|
const subject = this;
|
|
|
|
const messagesLength = subject.messages.length;
|
2022-04-07 07:06:43 +00:00
|
|
|
for (let i = 0; i < messagesLength; i++) {
|
2022-01-21 08:28:41 +00:00
|
|
|
(() => {
|
2022-04-07 07:06:43 +00:00
|
|
|
const { notification, frame } = subject.messages[i];
|
|
|
|
subject.scheduler.schedule(() => {
|
|
|
|
observeNotification(notification, subject);
|
|
|
|
}, frame);
|
2022-01-21 08:28:41 +00:00
|
|
|
})();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applyMixins(HotObservable, [SubscriptionLoggable]);
|
|
|
|
//# sourceMappingURL=HotObservable.js.map
|