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

CreateLiveQueryObserverOptions.md

69 lines2.0 KB

1---
2id: CreateLiveQueryObserverOptions
3title: CreateLiveQueryObserverOptions
4---
5​
6Defined in: [packages/db/src/live-query-observer.ts:1140](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L1140)
7​
8## Properties
9​
10### client?
11​
12```ts
13optional client: DbClient;
14```
15​
16Defined in: [packages/db/src/live-query-observer.ts:1157](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L1157)
17​
18DbClient cache that owns SSR snapshots for this query identity.
19​
20***
21​
22### mode?
23​
24```ts
25optional mode: "granular" | "wholesale";
26```
27​
28Defined in: [packages/db/src/live-query-observer.ts:1155](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L1155)
29​
30How subscribers consume the observer:
31​
32- `granular` (default): subscribers apply the delivered `ChangeMessage[]`
33 deltas to their own keyed state (Vue/Svelte/Solid). The observer
34 subscribes with initial state and seeds late subscribers, so every
35 subscriber converges from deltas alone.
36- `wholesale`: subscribers treat notifications as a wake-up and re-read
37 `getSnapshot()` (React/Angular). The observer subscribes WITHOUT initial
38 state, preserving those adapters' loading policy — no snapshot request,
39 so no unfiltered `loadSubset` against on-demand collections. Nothing is
40 delivered synchronously during `subscribe`, which keeps
41 `useSyncExternalStore`-style consumers safe by construction.
42​
43***
44​
45### onPreload()?
46​
47```ts
48optional onPreload: () => void;
49```
50​
51Defined in: [packages/db/src/live-query-observer.ts:1161](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L1161)
52​
53Resume framework-deferred query sources before a server preload.
54​
55#### Returns
56​
57`void`
58​
59***
60​
61### queryHash?
62​
63```ts
64optional queryHash: string;
65```
66​
67Defined in: [packages/db/src/live-query-observer.ts:1159](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L1159)
68​
69Stable live-query identity used for dehydration and hydration.