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

SubscribeChangesSnapshotOptions.md

266 lines5.0 KB

1---
2id: SubscribeChangesSnapshotOptions
3title: SubscribeChangesSnapshotOptions
4---
5​
6Defined in: [packages/db/src/types.ts:1179](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1179)
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:1147](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1147)
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:1184](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1184)
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:1171](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1171)
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:1169](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1169)
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:1153](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1153)
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:1183](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1183)
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### truncateReplayPublication?
175​
176```ts
177optional truncateReplayPublication: object;
178```
179​
180Defined in: [packages/db/src/types.ts:1173](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1173)
181​
182**`Internal`**
183​
184Lets a live-query graph retain its last publication during replay.
185​
186#### start()
187​
188```ts
189readonly start: () => void;
190```
191​
192##### Returns
193​
194`void`
195​
196#### succeed()
197​
198```ts
199readonly succeed: () => void;
200```
201​
202##### Returns
203​
204`void`
205​
206#### Inherited from
207​
208```ts
209Omit.truncateReplayPublication
210```
211​
212***
213​
214### where()?
215​
216```ts
217optional where: (row) => any;
218```
219​
220Defined in: [packages/db/src/types.ts:1136](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1136)
221​
222Callback function for filtering changes using a row proxy.
223The callback receives a proxy object that records property access,
224allowing you to use query builder functions like `eq`, `gt`, etc.
225​
226#### Parameters
227​
228##### row
229​
230`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>, `TKey`, `true`\>
231​
232#### Returns
233​
234`any`
235​
236#### Example
237​
238```ts
239import { eq } from "@tanstack/db"
240​
241collection.subscribeChanges(callback, {
242 where: (row) => eq(row.status, "active")
243})
244```
245​
246#### Inherited from
247​
248```ts
249Omit.where
250```
251​
252***
253​
254### whereExpression?
255​
256```ts
257optional whereExpression: BasicExpression<boolean>;
258```
259​
260Defined in: [packages/db/src/types.ts:1138](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1138)
261​
262Pre-compiled expression for filtering changes
263​
264#### Inherited from
265​
266[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`whereExpression`](SubscribeChangesOptions.md#whereexpression)