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

SubscribeChangesSnapshotOptions.md

324 lines6.0 KB

1---
2id: SubscribeChangesSnapshotOptions
3title: SubscribeChangesSnapshotOptions
4---
5​
6Defined in: [packages/db/src/types.ts:1315](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1315)
7​
8## Extends
9​
10- `Omit`\<[`SubscribeChangesOptions`](SubscribeChangesOptions.md)\<`T`, `TKey`\>, `"includeInitialState"`\>
11​
12## Type Parameters
13​
14### T
15​
16`T` *extends* `object` = `Record`\<`string`, `unknown`\>
17​
18### TKey
19​
20`TKey` *extends* `string` \| `number` = `string` \| `number`
21​
22## Properties
23​
24### deferAcquisition?
25​
26```ts
27optional deferAcquisition: boolean;
28```
29​
30Defined in: [packages/db/src/types.ts:1269](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1269)
31​
32**`Internal`**
33​
34Whether this subscription defers provider work. It keeps the Collection
35alive and reads its local rows, but starts no idle source sync run and no
36acquisition attempt until `subscription.resumeDeferredAcquisition()`. A
37live-query Collection defers its source subscriptions until it has a
38subscriber or a preload in its current sync run.
39​
40#### Inherited from
41​
42[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`deferAcquisition`](SubscribeChangesOptions.md#deferacquisition)
43​
44***
45​
46### limit?
47​
48```ts
49optional limit: number;
50```
51​
52Defined in: [packages/db/src/types.ts:1320](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1320)
53​
54**`Internal`**
55​
56Optional limit to include in loadSubset for query-specific cache keys.
57​
58#### Overrides
59​
60[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`limit`](SubscribeChangesOptions.md#limit)
61​
62***
63​
64### onLoadSubsetError()?
65​
66```ts
67optional onLoadSubsetError: (event) => void;
68```
69​
70Defined in: [packages/db/src/types.ts:1299](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1299)
71​
72**`Internal`**
73​
74Receives subset-load failures scoped to this subscription.
75​
76#### Parameters
77​
78##### event
79​
80[`SubscriptionLoadSubsetErrorEvent`](SubscriptionLoadSubsetErrorEvent.md)
81​
82#### Returns
83​
84`void`
85​
86#### Inherited from
87​
88```ts
89Omit.onLoadSubsetError
90```
91​
92***
93​
94### onLoadSubsetResult()?
95​
96```ts
97optional onLoadSubsetResult: (result) => void;
98```
99​
100Defined in: [packages/db/src/types.ts:1297](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1297)
101​
102**`Internal`**
103​
104Callback that receives the loadSubset result (Promise or true) from requestSnapshot.
105Allows the caller to directly track the loading promise for isReady status.
106​
107#### Parameters
108​
109##### result
110​
111[`LoadSubsetRequestResult`](../type-aliases/LoadSubsetRequestResult.md)
112​
113#### Returns
114​
115`void`
116​
117#### Inherited from
118​
119```ts
120Omit.onLoadSubsetResult
121```
122​
123***
124​
125### onStatusChange()?
126​
127```ts
128optional onStatusChange: (event) => void;
129```
130​
131Defined in: [packages/db/src/types.ts:1281](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1281)
132​
133**`Internal`**
134​
135Listener for subscription status changes.
136Registered BEFORE any snapshot is requested, ensuring no status transitions are missed.
137​
138#### Parameters
139​
140##### event
141​
142[`SubscriptionStatusChangeEvent`](SubscriptionStatusChangeEvent.md)
143​
144#### Returns
145​
146`void`
147​
148#### Inherited from
149​
150```ts
151Omit.onStatusChange
152```
153​
154***
155​
156### orderBy?
157​
158```ts
159optional orderBy: OrderBy;
160```
161​
162Defined in: [packages/db/src/types.ts:1319](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1319)
163​
164**`Internal`**
165​
166Optional orderBy to include in loadSubset for query-specific cache keys.
167​
168#### Overrides
169​
170[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`orderBy`](SubscribeChangesOptions.md#orderby)
171​
172***
173​
174### owner?
175​
176```ts
177optional owner: CollectionDependent;
178```
179​
180Defined in: [packages/db/src/types.ts:1275](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1275)
181​
182**`Internal`**
183​
184The live query or Effect this subscription reads for, so
185`collection.subscribers` can name it.
186​
187#### Inherited from
188​
189[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`owner`](SubscribeChangesOptions.md#owner)
190​
191***
192​
193### truncateReplayPublication?
194​
195```ts
196optional truncateReplayPublication: object;
197```
198​
199Defined in: [packages/db/src/types.ts:1301](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1301)
200​
201**`Internal`**
202​
203Lets a live-query graph retain its last publication during replay.
204​
205#### fail()?
206​
207```ts
208readonly optional fail: (errors) => void;
209```
210​
211The replay could not load every active demand again: its failures, in failure order.
212​
213##### Parameters
214​
215###### errors
216​
217`Error`[]
218​
219##### Returns
220​
221`void`
222​
223#### siblingReplays()
224​
225```ts
226readonly siblingReplays: () => Promise<unknown> | undefined;
227```
228​
229The replays of the graph's other subscriptions to this collection that
230still load. They share one barrier, so this replay waits for them.
231​
232##### Returns
233​
234`Promise`\<`unknown`\> \| `undefined`
235​
236#### start()
237​
238```ts
239readonly start: (retired) => void;
240```
241​
242`retired`: a reload retired the sync run, and no truncate came.
243​
244##### Parameters
245​
246###### retired
247​
248`boolean`
249​
250##### Returns
251​
252`void`
253​
254#### succeed()
255​
256```ts
257readonly succeed: () => void;
258```
259​
260##### Returns
261​
262`void`
263​
264#### Inherited from
265​
266```ts
267Omit.truncateReplayPublication
268```
269​
270***
271​
272### where()?
273​
274```ts
275optional where: (row) => any;
276```
277​
278Defined in: [packages/db/src/types.ts:1258](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1258)
279​
280Callback function for filtering changes using a row proxy.
281The callback receives a proxy object that records property access,
282allowing you to use query builder functions like `eq`, `gt`, etc.
283​
284#### Parameters
285​
286##### row
287​
288`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>, `TKey`, `true`\>
289​
290#### Returns
291​
292`any`
293​
294#### Example
295​
296```ts
297import { eq } from "@tanstack/db"
298​
299collection.subscribeChanges(callback, {
300 where: (row) => eq(row.status, "active")
301})
302```
303​
304#### Inherited from
305​
306```ts
307Omit.where
308```
309​
310***
311​
312### whereExpression?
313​
314```ts
315optional whereExpression: BasicExpression<boolean>;
316```
317​
318Defined in: [packages/db/src/types.ts:1260](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1260)
319​
320Pre-compiled expression for filtering changes
321​
322#### Inherited from
323​
324[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`whereExpression`](SubscribeChangesOptions.md#whereexpression)