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

SubscribeChangesSnapshotOptions.md

178 lines3.0 KB

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