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

SubscribeChangesSnapshotOptions.md

315 lines5.7 KB

1---
2id: SubscribeChangesSnapshotOptions
3title: SubscribeChangesSnapshotOptions
4---
5​
6Defined in: [packages/db/src/types.ts:1280](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1280)
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:1238](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1238)
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:1285](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1285)
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:1268](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1268)
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:1266](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1266)
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:1250](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1250)
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:1284](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1284)
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:1244](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1244)
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:1270](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1270)
200​
201**`Internal`**
202​
203Lets a live-query graph retain its last publication during replay.
204​
205#### fail()?
206​
207```ts
208readonly optional fail: (error) => void;
209```
210​
211The replay could not load every active demand again.
212​
213##### Parameters
214​
215###### error
216​
217`Error`
218​
219##### Returns
220​
221`void`
222​
223#### holdsDemand()?
224​
225```ts
226readonly optional holdsDemand: () => boolean;
227```
228​
229The live query still holds logical demand.
230​
231##### Returns
232​
233`boolean`
234​
235#### start()
236​
237```ts
238readonly start: () => void;
239```
240​
241##### Returns
242​
243`void`
244​
245#### succeed()
246​
247```ts
248readonly succeed: () => void;
249```
250​
251##### Returns
252​
253`void`
254​
255#### Inherited from
256​
257```ts
258Omit.truncateReplayPublication
259```
260​
261***
262​
263### where()?
264​
265```ts
266optional where: (row) => any;
267```
268​
269Defined in: [packages/db/src/types.ts:1227](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1227)
270​
271Callback function for filtering changes using a row proxy.
272The callback receives a proxy object that records property access,
273allowing you to use query builder functions like `eq`, `gt`, etc.
274​
275#### Parameters
276​
277##### row
278​
279`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>, `TKey`, `true`\>
280​
281#### Returns
282​
283`any`
284​
285#### Example
286​
287```ts
288import { eq } from "@tanstack/db"
289​
290collection.subscribeChanges(callback, {
291 where: (row) => eq(row.status, "active")
292})
293```
294​
295#### Inherited from
296​
297```ts
298Omit.where
299```
300​
301***
302​
303### whereExpression?
304​
305```ts
306optional whereExpression: BasicExpression<boolean>;
307```
308​
309Defined in: [packages/db/src/types.ts:1229](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1229)
310​
311Pre-compiled expression for filtering changes
312​
313#### Inherited from
314​
315[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`whereExpression`](SubscribeChangesOptions.md#whereexpression)