Skip to main content

Class: ComputedStateManager

Defined in: utils/state/core/computedStateManager.ts:113

Manages derived values that recompute from state dependencies.

Constructors​

Constructor​

new ComputedStateManager(): ComputedStateManager;

Returns​

ComputedStateManager

Properties​

computedValues​

private readonly computedValues: Map<string, ComputedValue>;

Defined in: utils/state/core/computedStateManager.ts:114


dependencies​

private readonly dependencies: Map<string, string[]>;

Defined in: utils/state/core/computedStateManager.ts:116


isComputing​

private readonly isComputing: Set<string>;

Defined in: utils/state/core/computedStateManager.ts:118


subscriptions​

private readonly subscriptions: Map<string, Unsubscribe[]>;

Defined in: utils/state/core/computedStateManager.ts:120

Methods​

addComputed()​

addComputed(
key: string,
computeFn: ComputedFunction,
deps?: string[]
): Unsubscribe;

Defined in: utils/state/core/computedStateManager.ts:125

Registers a computed value and subscribes it to dependency invalidations.

Parameters​

key​

string

computeFn​

ComputedFunction

deps?​

string[] = []

Returns​

Unsubscribe


cleanup()​

cleanup(): void;

Defined in: utils/state/core/computedStateManager.ts:168

Cleans up all computed values and dependency subscriptions.

Returns​

void


computeValue()​

computeValue(key: string): void;

Defined in: utils/state/core/computedStateManager.ts:184

Computes a value by key if it exists and is not already computing.

Parameters​

key​

string

Returns​

void


getAllComputed()​

getAllComputed(): ComputedSnapshot;

Defined in: utils/state/core/computedStateManager.ts:233

Gets all computed values with metadata.

Returns​

ComputedSnapshot


getComputed()​

getComputed(key: string): unknown;

Defined in: utils/state/core/computedStateManager.ts:250

Gets a computed value, recomputing invalid entries first.

Parameters​

key​

string

Returns​

unknown


getDependencyGraph()​

getDependencyGraph(): DependencyGraph;

Defined in: utils/state/core/computedStateManager.ts:267

Gets dependency relationships for debugging.

Returns​

DependencyGraph


invalidateComputed()​

invalidateComputed(key: string): void;

Defined in: utils/state/core/computedStateManager.ts:278

Marks a computed value as stale.

Parameters​

key​

string

Returns​

void


recomputeAll()​

recomputeAll(): void;

Defined in: utils/state/core/computedStateManager.ts:291

Forces recomputation of all computed values.

Returns​

void


removeComputed()​

removeComputed(key: string): void;

Defined in: utils/state/core/computedStateManager.ts:301

Removes a computed value and its dependency subscriptions.

Parameters​

key​

string

Returns​

void