Skip to main content

EffectConfig

还没翻译译自英文(tanstack.com)本页 48 段都还没译

Defined in: packages/db/src/query/effect.ts:107

Effect configuration

Type Parameters

TRow

TRow extends object = Record<string, unknown>

TKey

TKey extends string | number = string | number

Properties

id?

optional id: string;

Defined in: packages/db/src/query/effect.ts:112

Optional ID for debugging/tracing


onBatch?

optional onBatch: EffectBatchHandler<TRow, TKey>;

Defined in: packages/db/src/query/effect.ts:127

Called once per graph run with all delta events from that batch


onEnter?

optional onEnter: EffectEventHandler<TRow, TKey>;

Defined in: packages/db/src/query/effect.ts:118

Called once for each row entering the query result


onError()?

optional onError: (error, event) => void;

Defined in: packages/db/src/query/effect.ts:130

Error handler for exceptions thrown by effect callbacks

Parameters

error

Error

event

DeltaEvent<TRow, TKey>

Returns

void


onExit?

optional onExit: EffectEventHandler<TRow, TKey>;

Defined in: packages/db/src/query/effect.ts:124

Called once for each row exiting the query result


onSourceError()?

optional onSourceError: (error) => void;

Defined in: packages/db/src/query/effect.ts:137

Called when a source collection enters an error or cleaned-up state. The effect is automatically disposed after this callback fires. If not provided, the error is logged to console.error.

Parameters

error

Error

Returns

void


onUpdate?

optional onUpdate: EffectEventHandler<TRow, TKey>;

Defined in: packages/db/src/query/effect.ts:121

Called once for each row updating within the query result


query

query: EffectQueryInput<any>;

Defined in: packages/db/src/query/effect.ts:115

Query to watch for deltas


skipInitial?

optional skipInitial: boolean;

Defined in: packages/db/src/query/effect.ts:144

Skip deltas during initial collection load. Defaults to false (process all deltas including initial sync). Set to true for effects that should only process new changes.