Skip to main content

EffectScheduler<Result>

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 Signia with a framework of some kind.

Instead, use the react and reactor functions.

Example

const render = new EffectScheduler('render', drawToCanvas)

render.attach()
render.execute()

Type parameters

  • Result

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor()

Signature

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

Type parameters

  • Result

Parameters

NameType
namestring
runEffect(lastReactedEpoch: number) => Result
options?EffectSchedulerOptions

Returns

EffectScheduler<Result>

Defined in: signia/src/EffectScheduler.ts:85

Properties

name

Readonly string

Defined in: signia/src/EffectScheduler.ts:86

Accessors

isActivelyListening

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

Signature

isActivelyListening(): boolean;

Returns

boolean

Defined in: signia/src/EffectScheduler.ts:63

Defined in: signia/src/EffectScheduler.ts:63

scheduleCount

The number of times this effect has been scheduled.

Signature

scheduleCount(): number;

Returns

number

Defined in: signia/src/EffectScheduler.ts:76

Defined in: signia/src/EffectScheduler.ts:76

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.

Signature

attach(): void;

Returns

void

Defined in: signia/src/EffectScheduler.ts:133

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.

Signature

detach(): void;

Returns

void

Defined in: signia/src/EffectScheduler.ts:144

execute()

Executes the effect immediately and returns the result.

Signature

execute(): Result;

Returns

Result

The result of the effect.

Defined in: signia/src/EffectScheduler.ts:155