38 lines
1.3 KiB
JavaScript
Executable File
38 lines
1.3 KiB
JavaScript
Executable File
import { Observable } from '../Observable';
|
|
import { asap } from '../scheduler/asap';
|
|
import { isNumeric } from '../util/isNumeric';
|
|
/**
|
|
* We need this JSDoc comment for affecting ESDoc.
|
|
* @extends {Ignored}
|
|
* @hide true
|
|
*/
|
|
export class SubscribeOnObservable extends Observable {
|
|
constructor(source, delayTime = 0, scheduler = asap) {
|
|
super();
|
|
this.source = source;
|
|
this.delayTime = delayTime;
|
|
this.scheduler = scheduler;
|
|
if (!isNumeric(delayTime) || delayTime < 0) {
|
|
this.delayTime = 0;
|
|
}
|
|
if (!scheduler || typeof scheduler.schedule !== 'function') {
|
|
this.scheduler = asap;
|
|
}
|
|
}
|
|
static create(source, delay = 0, scheduler = asap) {
|
|
return new SubscribeOnObservable(source, delay, scheduler);
|
|
}
|
|
static dispatch(arg) {
|
|
const { source, subscriber } = arg;
|
|
return this.add(source.subscribe(subscriber));
|
|
}
|
|
/** @deprecated internal use only */ _subscribe(subscriber) {
|
|
const delay = this.delayTime;
|
|
const source = this.source;
|
|
const scheduler = this.scheduler;
|
|
return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
|
|
source, subscriber
|
|
});
|
|
}
|
|
}
|
|
//# sourceMappingURL=SubscribeOnObservable.js.map
|