mirror of
https://github.com/biobulkbende/biobulkbende.org.git
synced 2024-12-27 05:15:25 +00:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import { Observable } from '../Observable';
|
|
/**
|
|
* We need this JSDoc comment for affecting ESDoc.
|
|
* @extends {Ignored}
|
|
* @hide true
|
|
*/
|
|
export class ScalarObservable extends Observable {
|
|
constructor(value, scheduler) {
|
|
super();
|
|
this.value = value;
|
|
this.scheduler = scheduler;
|
|
this._isScalar = true;
|
|
if (scheduler) {
|
|
this._isScalar = false;
|
|
}
|
|
}
|
|
static create(value, scheduler) {
|
|
return new ScalarObservable(value, scheduler);
|
|
}
|
|
static dispatch(state) {
|
|
const { done, value, subscriber } = state;
|
|
if (done) {
|
|
subscriber.complete();
|
|
return;
|
|
}
|
|
subscriber.next(value);
|
|
if (subscriber.closed) {
|
|
return;
|
|
}
|
|
state.done = true;
|
|
this.schedule(state);
|
|
}
|
|
/** @deprecated internal use only */ _subscribe(subscriber) {
|
|
const value = this.value;
|
|
const scheduler = this.scheduler;
|
|
if (scheduler) {
|
|
return scheduler.schedule(ScalarObservable.dispatch, 0, {
|
|
done: false, value, subscriber
|
|
});
|
|
}
|
|
else {
|
|
subscriber.next(value);
|
|
if (!subscriber.closed) {
|
|
subscriber.complete();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//# sourceMappingURL=ScalarObservable.js.map
|