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

EffectConfig.md

154 lines3.0 KB

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