Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

EffectConfig.md

156 lines3.0 KB

1---
2id: EffectConfig
3title: EffectConfig
4---
5​
6# Interface: EffectConfig\<TRow, TKey\>
7​
8Defined in: [packages/db/src/query/effect.ts:93](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L93)
9​
10Effect configuration
11​
12## Type Parameters
13​
14### TRow
15​
16`TRow` *extends* `object` = `Record`\<`string`, `unknown`\>
17​
18### TKey
19​
20`TKey` *extends* `string` \| `number` = `string` \| `number`
21​
22## Properties
23​
24### id?
25​
26```ts
27optional id: string;
28```
29​
30Defined in: [packages/db/src/query/effect.ts:98](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L98)
31​
32Optional ID for debugging/tracing
33​
34***
35​
36### onBatch?
37​
38```ts
39optional onBatch: EffectBatchHandler<TRow, TKey>;
40```
41​
42Defined in: [packages/db/src/query/effect.ts:113](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L113)
43​
44Called once per graph run with all delta events from that batch
45​
46***
47​
48### onEnter?
49​
50```ts
51optional onEnter: EffectEventHandler<TRow, TKey>;
52```
53​
54Defined in: [packages/db/src/query/effect.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L104)
55​
56Called once for each row entering the query result
57​
58***
59​
60### onError()?
61​
62```ts
63optional onError: (error, event) => void;
64```
65​
66Defined in: [packages/db/src/query/effect.ts:116](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L116)
67​
68Error handler for exceptions thrown by effect callbacks
69​
70#### Parameters
71​
72##### error
73​
74`Error`
75​
76##### event
77​
78[`DeltaEvent`](../type-aliases/DeltaEvent.md)\<`TRow`, `TKey`\>
79​
80#### Returns
81​
82`void`
83​
84***
85​
86### onExit?
87​
88```ts
89optional onExit: EffectEventHandler<TRow, TKey>;
90```
91​
92Defined in: [packages/db/src/query/effect.ts:110](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L110)
93​
94Called once for each row exiting the query result
95​
96***
97​
98### onSourceError()?
99​
100```ts
101optional onSourceError: (error) => void;
102```
103​
104Defined in: [packages/db/src/query/effect.ts:123](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L123)
105​
106Called when a source collection enters an error or cleaned-up state.
107The effect is automatically disposed after this callback fires.
108If not provided, the error is logged to console.error.
109​
110#### Parameters
111​
112##### error
113​
114`Error`
115​
116#### Returns
117​
118`void`
119​
120***
121​
122### onUpdate?
123​
124```ts
125optional onUpdate: EffectEventHandler<TRow, TKey>;
126```
127​
128Defined in: [packages/db/src/query/effect.ts:107](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L107)
129​
130Called once for each row updating within the query result
131​
132***
133​
134### query
135​
136```ts
137query: EffectQueryInput<any>;
138```
139​
140Defined in: [packages/db/src/query/effect.ts:101](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L101)
141​
142Query to watch for deltas
143​
144***
145​
146### skipInitial?
147​
148```ts
149optional skipInitial: boolean;
150```
151​
152Defined in: [packages/db/src/query/effect.ts:130](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L130)
153​
154Skip deltas during initial collection load.
155Defaults to false (process all deltas including initial sync).
156Set to true for effects that should only process new changes.