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

SubscribeChangesSnapshotOptions.md

244 lines4.3 KB

1---
2id: SubscribeChangesSnapshotOptions
3title: SubscribeChangesSnapshotOptions
4---
5​
6Defined in: [packages/db/src/types.ts:1126](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1126)
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### limit?
25​
26```ts
27optional limit: number;
28```
29​
30Defined in: [packages/db/src/types.ts:1131](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1131)
31​
32**`Internal`**
33​
34Optional limit to include in loadSubset for query-specific cache keys.
35​
36#### Overrides
37​
38[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`limit`](SubscribeChangesOptions.md#limit)
39​
40***
41​
42### onLoadSubsetError()?
43​
44```ts
45optional onLoadSubsetError: (event) => void;
46```
47​
48Defined in: [packages/db/src/types.ts:1118](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1118)
49​
50**`Internal`**
51​
52Receives subset-load failures scoped to this subscription.
53​
54#### Parameters
55​
56##### event
57​
58[`SubscriptionLoadSubsetErrorEvent`](SubscriptionLoadSubsetErrorEvent.md)
59​
60#### Returns
61​
62`void`
63​
64#### Inherited from
65​
66```ts
67Omit.onLoadSubsetError
68```
69​
70***
71​
72### onLoadSubsetResult()?
73​
74```ts
75optional onLoadSubsetResult: (result) => void;
76```
77​
78Defined in: [packages/db/src/types.ts:1116](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1116)
79​
80**`Internal`**
81​
82Callback that receives the loadSubset result (Promise or true) from requestSnapshot.
83Allows the caller to directly track the loading promise for isReady status.
84​
85#### Parameters
86​
87##### result
88​
89[`LoadSubsetRequestResult`](../type-aliases/LoadSubsetRequestResult.md)
90​
91#### Returns
92​
93`void`
94​
95#### Inherited from
96​
97```ts
98Omit.onLoadSubsetResult
99```
100​
101***
102​
103### onStatusChange()?
104​
105```ts
106optional onStatusChange: (event) => void;
107```
108​
109Defined in: [packages/db/src/types.ts:1100](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1100)
110​
111**`Internal`**
112​
113Listener for subscription status changes.
114Registered BEFORE any snapshot is requested, ensuring no status transitions are missed.
115​
116#### Parameters
117​
118##### event
119​
120[`SubscriptionStatusChangeEvent`](SubscriptionStatusChangeEvent.md)
121​
122#### Returns
123​
124`void`
125​
126#### Inherited from
127​
128```ts
129Omit.onStatusChange
130```
131​
132***
133​
134### orderBy?
135​
136```ts
137optional orderBy: OrderBy;
138```
139​
140Defined in: [packages/db/src/types.ts:1130](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1130)
141​
142**`Internal`**
143​
144Optional orderBy to include in loadSubset for query-specific cache keys.
145​
146#### Overrides
147​
148[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`orderBy`](SubscribeChangesOptions.md#orderby)
149​
150***
151​
152### truncateReplayPublication?
153​
154```ts
155optional truncateReplayPublication: object;
156```
157​
158Defined in: [packages/db/src/types.ts:1120](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1120)
159​
160**`Internal`**
161​
162Lets a live-query graph retain its last publication during replay.
163​
164#### start()
165​
166```ts
167readonly start: () => void;
168```
169​
170##### Returns
171​
172`void`
173​
174#### succeed()
175​
176```ts
177readonly succeed: () => void;
178```
179​
180##### Returns
181​
182`void`
183​
184#### Inherited from
185​
186```ts
187Omit.truncateReplayPublication
188```
189​
190***
191​
192### where()?
193​
194```ts
195optional where: (row) => any;
196```
197​
198Defined in: [packages/db/src/types.ts:1092](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1092)
199​
200Callback function for filtering changes using a row proxy.
201The callback receives a proxy object that records property access,
202allowing you to use query builder functions like `eq`, `gt`, etc.
203​
204#### Parameters
205​
206##### row
207​
208`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>, `TKey`, `true`\>
209​
210#### Returns
211​
212`any`
213​
214#### Example
215​
216```ts
217import { eq } from "@tanstack/db"
218​
219collection.subscribeChanges(callback, {
220 where: (row) => eq(row.status, "active")
221})
222```
223​
224#### Inherited from
225​
226```ts
227Omit.where
228```
229​
230***
231​
232### whereExpression?
233​
234```ts
235optional whereExpression: BasicExpression<boolean>;
236```
237​
238Defined in: [packages/db/src/types.ts:1094](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1094)
239​
240Pre-compiled expression for filtering changes
241​
242#### Inherited from
243​
244[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`whereExpression`](SubscribeChangesOptions.md#whereexpression)