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

CreateLiveQueryObserverOptions.md

71 lines2.0 KB

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