Skip to content

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

ts
new PassthroughScheduler(parent, pinningSubject?): PassthroughScheduler

Parameters

ParameterType
parentSchedulerLike
pinningSubject?SchedulerSubject

Returns

PassthroughScheduler

Properties

parent

ts
protected readonly parent: SchedulerLike;

pinningSubject?

ts
protected readonly optional pinningSubject: SchedulerSubject;

Methods

add()

ts
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

ParameterTypeDescription
subjectSchedulerSubjectThe subject that "owns" the promise.
promisePromiseLike<void>The promise to be added to the subject.

Returns

void

Implementation of

SchedulerLike.add


dispose()

ts
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

ParameterTypeDescription
subjectSchedulerSubjectThe observable or subscriber to dispose

Returns

Promise<void>

A promise that resolves when disposal is complete

Implementation of

SchedulerLike.dispose


promise()

ts
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

ParameterTypeDescription
subjectSchedulerSubjectThe observable or subscriber to wait for completion

Returns

Promise<void>

A promise that resolves when all work is complete

Implementation of

SchedulerLike.promise


schedule()

ts
schedule(subject, action): void

Schedules an action that is "owned" by the subject that will be executed by the parent scheduler.

Parameters

ParameterTypeDescription
subjectSchedulerSubjectThe subject that "owns" the action.
actionScheduledAction<any>The action to be scheduled.

Returns

void

Implementation of

SchedulerLike.schedule

Released under the MIT License.