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

SubscribeChangesSnapshotOptions.md

206 lines3.8 KB

1---
2id: SubscribeChangesSnapshotOptions
3title: SubscribeChangesSnapshotOptions
4---
5​
6# Interface: SubscribeChangesSnapshotOptions\<T, TKey\>
7​
8Defined in: [packages/db/src/types.ts:941](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L941)
9​
10## Extends
11​
12- `Omit`\<[`SubscribeChangesOptions`](SubscribeChangesOptions.md)\<`T`, `TKey`\>, `"includeInitialState"`\>
13​
14## Type Parameters
15​
16### T
17​
18`T` *extends* `object` = `Record`\<`string`, `unknown`\>
19​
20### TKey
21​
22`TKey` *extends* `string` \| `number` = `string` \| `number`
23​
24## Properties
25​
26### limit?
27​
28```ts
29optional limit: number;
30```
31​
32Defined in: [packages/db/src/types.ts:946](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L946)
33​
34**`Internal`**
35​
36Optional limit to include in loadSubset for query-specific cache keys.
37​
38#### Overrides
39​
40[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`limit`](SubscribeChangesOptions.md#limit)
41​
42***
43​
44### onLoadSubsetError()?
45​
46```ts
47optional onLoadSubsetError: (event) => void;
48```
49​
50Defined in: [packages/db/src/types.ts:938](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L938)
51​
52**`Internal`**
53​
54Receives subset-load failures scoped to this subscription.
55​
56#### Parameters
57​
58##### event
59​
60[`SubscriptionLoadSubsetErrorEvent`](SubscriptionLoadSubsetErrorEvent.md)
61​
62#### Returns
63​
64`void`
65​
66#### Inherited from
67​
68```ts
69Omit.onLoadSubsetError
70```
71​
72***
73​
74### onLoadSubsetResult()?
75​
76```ts
77optional onLoadSubsetResult: (result) => void;
78```
79​
80Defined in: [packages/db/src/types.ts:936](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L936)
81​
82**`Internal`**
83​
84Callback that receives the loadSubset result (Promise or true) from requestSnapshot.
85Allows the caller to directly track the loading promise for isReady status.
86​
87#### Parameters
88​
89##### result
90​
91`true` | `Promise`\<`void`\>
92​
93#### Returns
94​
95`void`
96​
97#### Inherited from
98​
99```ts
100Omit.onLoadSubsetResult
101```
102​
103***
104​
105### onStatusChange()?
106​
107```ts
108optional onStatusChange: (event) => void;
109```
110​
111Defined in: [packages/db/src/types.ts:920](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L920)
112​
113**`Internal`**
114​
115Listener for subscription status changes.
116Registered BEFORE any snapshot is requested, ensuring no status transitions are missed.
117​
118#### Parameters
119​
120##### event
121​
122[`SubscriptionStatusChangeEvent`](SubscriptionStatusChangeEvent.md)
123​
124#### Returns
125​
126`void`
127​
128#### Inherited from
129​
130```ts
131Omit.onStatusChange
132```
133​
134***
135​
136### orderBy?
137​
138```ts
139optional orderBy: OrderBy;
140```
141​
142Defined in: [packages/db/src/types.ts:945](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L945)
143​
144**`Internal`**
145​
146Optional orderBy to include in loadSubset for query-specific cache keys.
147​
148#### Overrides
149​
150[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`orderBy`](SubscribeChangesOptions.md#orderby)
151​
152***
153​
154### where()?
155​
156```ts
157optional where: (row) => any;
158```
159​
160Defined in: [packages/db/src/types.ts:912](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L912)
161​
162Callback function for filtering changes using a row proxy.
163The callback receives a proxy object that records property access,
164allowing you to use query builder functions like `eq`, `gt`, etc.
165​
166#### Parameters
167​
168##### row
169​
170`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\>
171​
172#### Returns
173​
174`any`
175​
176#### Example
177​
178```ts
179import { eq } from "@tanstack/db"
180​
181collection.subscribeChanges(callback, {
182 where: (row) => eq(row.status, "active")
183})
184```
185​
186#### Inherited from
187​
188```ts
189Omit.where
190```
191​
192***
193​
194### whereExpression?
195​
196```ts
197optional whereExpression: BasicExpression<boolean>;
198```
199​
200Defined in: [packages/db/src/types.ts:914](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L914)
201​
202Pre-compiled expression for filtering changes
203​
204#### Inherited from
205​
206[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`whereExpression`](SubscribeChangesOptions.md#whereexpression)