Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[6a3a178] | 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 |
---|
Note:
See
TracBrowser
for help on using the repository browser.