EffectScheduler

See source code

Interface

Table of contents
interface EffectScheduler<Result> {}

Properties

isActivelyListening

readonly

Whether this scheduler is attached and actively listening to its parents.

readonly isActivelyListening: boolean;

name

readonly
readonly name: string;

scheduleCount

readonly

The number of times this effect has been scheduled.

readonly scheduleCount: number;

Methods

attach

Makes this scheduler become 'actively listening' to its parents. If it has been executed before it will immediately become eligible to receive 'maybeScheduleEffect' calls. If it has not executed before it will need to be manually executed once to become eligible for scheduling, i.e. by calling EffectScheduler.execute.


detach

Makes this scheduler stop 'actively listening' to its parents. It will no longer be eligible to receive 'maybeScheduleEffect' calls until EffectScheduler.attach is called again.


execute

Executes the effect immediately and returns the result.


Value

An EffectScheduler is responsible for executing side effects in response to changes in state.

You probably don't need to use this directly unless you're integrating this library with a framework of some kind.

Instead, use the react and reactor functions.

EffectScheduler: new <Result>(
  name: string,
  runEffect: (lastReactedEpoch: number) => Result,
  options?: EffectSchedulerOptions,
) => EffectScheduler<Result>;

Example

const render = new EffectScheduler("render", drawToCanvas);

render.attach();
render.execute();
Prev
MERMAID_MINDMAP_NODE_TYPE
Next
EMPTY_ARRAY