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.3 KB
|
Line | |
---|
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 |
---|
Note:
See
TracBrowser
for help on using the repository browser.