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.
34 lines
1.3 KiB
34 lines
1.3 KiB
import { Observable } from '../Observable'; |
|
import { Subscription } from '../Subscription'; |
|
import { SubscriptionLoggable } from './SubscriptionLoggable'; |
|
import { applyMixins } from '../util/applyMixins'; |
|
/** |
|
* We need this JSDoc comment for affecting ESDoc. |
|
* @ignore |
|
* @extends {Ignored} |
|
*/ |
|
export class ColdObservable extends Observable { |
|
constructor(messages, scheduler) { |
|
super(function (subscriber) { |
|
const observable = this; |
|
const index = observable.logSubscribedFrame(); |
|
subscriber.add(new Subscription(() => { |
|
observable.logUnsubscribedFrame(index); |
|
})); |
|
observable.scheduleMessages(subscriber); |
|
return subscriber; |
|
}); |
|
this.messages = messages; |
|
this.subscriptions = []; |
|
this.scheduler = scheduler; |
|
} |
|
scheduleMessages(subscriber) { |
|
const messagesLength = this.messages.length; |
|
for (let i = 0; i < messagesLength; i++) { |
|
const message = this.messages[i]; |
|
subscriber.add(this.scheduler.schedule(({ message, subscriber }) => { message.notification.observe(subscriber); }, message.frame, { message, subscriber })); |
|
} |
|
} |
|
} |
|
applyMixins(ColdObservable, [SubscriptionLoggable]); |
|
//# sourceMappingURL=ColdObservable.js.map
|