Documentation / @eventkit/base / PassthroughScheduler
Class: PassthroughScheduler
A scheduler that passes through all of it's work to a parent scheduler, and also defers the execution of scheduled actions to the parent scheduler. Optionally, a subject can be passed in the constructor to attach any work given to this scheduler to the subject in the parent scheduler.
This is helpful to isolate and independently observe subsets of the work of a parent scheduler. Work that is pinned to a subject here will also be observed by the parent scheduler, but this scheduler won't have any visibility into any other work that's being done by the parent scheduler. (i.e. we can independently await three distinct observable's that are observing a parent observable, or we can await the parent observable directly)
Extended by
Implements
Constructors
Constructor
new PassthroughScheduler(parent, pinningSubject?): PassthroughScheduler
Parameters
Parameter | Type |
---|---|
parent | SchedulerLike |
pinningSubject ? | SchedulerSubject |
Returns
PassthroughScheduler
Properties
parent
protected readonly parent: SchedulerLike;
pinningSubject?
protected readonly optional pinningSubject: SchedulerSubject;
Methods
add()
add(subject, promise): void
Adds a promise that is "owned" by a subject. This means that the promise will be observed by the scheduler and will be used to determine when the subject's work has completed. If a pinning subject is provided in the constructor, the promise will also be added to that subject in the parent scheduler
Parameters
Parameter | Type | Description |
---|---|---|
subject | SchedulerSubject | The subject that "owns" the promise. |
promise | PromiseLike <void > | The promise to be added to the subject. |
Returns
void
Implementation of
dispose()
dispose(subject): Promise<void>
Disposes of a subject early, canceling any pending work. This is what's called when you await observable.cancel()
or await subscriber.cancel()
.
Parameters
Parameter | Type | Description |
---|---|---|
subject | SchedulerSubject | The observable or subscriber to dispose |
Returns
Promise
<void
>
A promise that resolves when disposal is complete
Implementation of
promise()
promise(subject): Promise<void>
Returns a promise that resolves when all work associated with the subject is complete. This is what's called when you await observable.drain()
or await subscriber
.
Parameters
Parameter | Type | Description |
---|---|---|
subject | SchedulerSubject | The observable or subscriber to wait for completion |
Returns
Promise
<void
>
A promise that resolves when all work is complete
Implementation of
schedule()
schedule(subject, action): void
Schedules an action that is "owned" by the subject that will be executed by the parent scheduler.
Parameters
Parameter | Type | Description |
---|---|---|
subject | SchedulerSubject | The subject that "owns" the action. |
action | ScheduledAction <any > | The action to be scheduled. |
Returns
void