Open History to see the last commit
1---
2id: SubscribeChangesOptions
3title: SubscribeChangesOptions
4---
5
6Defined in: [packages/db/src/types.ts:1116](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1116)
7
8Options for subscribing to collection changes
9
10## Type Parameters
11
12### T
13
14`T` *extends* `object` = `Record`\<`string`, `unknown`\>
15
16### TKey
17
18`TKey` *extends* `string` \| `number` = `string` \| `number`
19
20## Properties
21
22### deferAcquisition?
23
24```ts
25optional deferAcquisition: boolean;
26```
27
28Defined in: [packages/db/src/types.ts:1147](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1147)
29
30**`Internal`**
31
32Whether this subscription defers provider work. It keeps the Collection
33alive and reads its local rows, but starts no idle source sync run and no
34acquisition attempt until `subscription.resumeDeferredAcquisition()`. A
35live-query Collection defers its source subscriptions until it has a
36subscriber or a preload in its current sync run.
37
38***
39
40### includeInitialState?
41
42```ts
43optional includeInitialState: boolean;
44```
45
46Defined in: [packages/db/src/types.ts:1121](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1121)
47
48Whether to include the current state as initial changes
49
50***
51
52### limit?
53
54```ts
55optional limit: number;
56```
57
58Defined in: [packages/db/src/types.ts:1163](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1163)
59
60**`Internal`**
61
62Optional limit to include in loadSubset for query-specific cache keys.
63
64***
65
66### onLoadSubsetError()?
67
68```ts
69optional onLoadSubsetError: (event) => void;
70```
71
72Defined in: [packages/db/src/types.ts:1171](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1171)
73
74**`Internal`**
75
76Receives subset-load failures scoped to this subscription.
77
78#### Parameters
79
80##### event
81
82[`SubscriptionLoadSubsetErrorEvent`](SubscriptionLoadSubsetErrorEvent.md)
83
84#### Returns
85
86`void`
87
88***
89
90### onLoadSubsetResult()?
91
92```ts
93optional onLoadSubsetResult: (result) => void;
94```
95
96Defined in: [packages/db/src/types.ts:1169](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1169)
97
98**`Internal`**
99
100Callback that receives the loadSubset result (Promise or true) from requestSnapshot.
101Allows the caller to directly track the loading promise for isReady status.
102
103#### Parameters
104
105##### result
106
107[`LoadSubsetRequestResult`](../type-aliases/LoadSubsetRequestResult.md)
108
109#### Returns
110
111`void`
112
113***
114
115### onStatusChange()?
116
117```ts
118optional onStatusChange: (event) => void;
119```
120
121Defined in: [packages/db/src/types.ts:1153](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1153)
122
123**`Internal`**
124
125Listener for subscription status changes.
126Registered BEFORE any snapshot is requested, ensuring no status transitions are missed.
127
128#### Parameters
129
130##### event
131
132[`SubscriptionStatusChangeEvent`](SubscriptionStatusChangeEvent.md)
133
134#### Returns
135
136`void`
137
138***
139
140### orderBy?
141
142```ts
143optional orderBy: OrderBy;
144```
145
146Defined in: [packages/db/src/types.ts:1158](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1158)
147
148**`Internal`**
149
150Optional orderBy to include in loadSubset for query-specific cache keys.
151
152***
153
154### truncateReplayPublication?
155
156```ts
157optional truncateReplayPublication: object;
158```
159
160Defined in: [packages/db/src/types.ts:1173](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1173)
161
162**`Internal`**
163
164Lets a live-query graph retain its last publication during replay.
165
166#### start()
167
168```ts
169readonly start: () => void;
170```
171
172##### Returns
173
174`void`
175
176#### succeed()
177
178```ts
179readonly succeed: () => void;
180```
181
182##### Returns
183
184`void`
185
186***
187
188### where()?
189
190```ts
191optional where: (row) => any;
192```
193
194Defined in: [packages/db/src/types.ts:1136](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1136)
195
196Callback function for filtering changes using a row proxy.
197The callback receives a proxy object that records property access,
198allowing you to use query builder functions like `eq`, `gt`, etc.
199
200#### Parameters
201
202##### row
203
204`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>, `TKey`, `true`\>
205
206#### Returns
207
208`any`
209
210#### Example
211
212```ts
213import { eq } from "@tanstack/db"
214
215collection.subscribeChanges(callback, {
216 where: (row) => eq(row.status, "active")
217})
218```
219
220***
221
222### whereExpression?
223
224```ts
225optional whereExpression: BasicExpression<boolean>;
226```
227
228Defined in: [packages/db/src/types.ts:1138](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L1138)
229
230Pre-compiled expression for filtering changes