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

useLiveInfiniteQuery.md

99 lines2.3 KB

1---
2id: useLiveInfiniteQuery
3title: useLiveInfiniteQuery
4---
5​
6# Function: useLiveInfiniteQuery()
7​
8## Call Signature
9​
10```ts
11function useLiveInfiniteQuery<TResult, TKey, TUtils>(liveQueryCollection, config): UseLiveInfiniteQueryReturn<any>;
12```
13​
14Defined in: [useLiveInfiniteQuery.ts:116](https://github.com/TanStack/db/blob/main/packages/react-db/src/useLiveInfiniteQuery.ts#L116)
15​
16Create an infinite query using a query function with live updates.
17​
18Uses `utils.setWindow()` to dynamically adjust the limit/offset window
19without recreating the live query collection on each page change.
20​
21### Type Parameters
22​
23#### TResult
24​
25`TResult` *extends* `object`
26​
27#### TKey
28​
29`TKey` *extends* `string` \| `number`
30​
31#### TUtils
32​
33`TUtils` *extends* `Record`\<`string`, `any`\>
34​
35### Parameters
36​
37#### liveQueryCollection
38​
39`Collection`\<`TResult`, `TKey`, `TUtils`, `StandardSchemaV1`\<`unknown`, `unknown`\>, `TResult`\> & `NonSingleResult`
40​
41#### config
42​
43[`UseLiveInfiniteQueryConfig`](../type-aliases/UseLiveInfiniteQueryConfig.md)\<`any`\>
44​
45Configuration including pageSize and getNextPageParam
46​
47### Returns
48​
49[`UseLiveInfiniteQueryReturn`](../type-aliases/UseLiveInfiniteQueryReturn.md)\<`any`\>
50​
51Object with pages, data, and pagination controls
52​
53## Call Signature
54​
55```ts
56function useLiveInfiniteQuery<TContext>(
57 queryFn,
58 config,
59deps?): UseLiveInfiniteQueryReturn<TContext>;
60```
61​
62Defined in: [useLiveInfiniteQuery.ts:126](https://github.com/TanStack/db/blob/main/packages/react-db/src/useLiveInfiniteQuery.ts#L126)
63​
64Create an infinite query using a query function with live updates.
65​
66Uses `utils.setWindow()` to dynamically adjust the limit/offset window
67without recreating the live query collection on each page change.
68​
69### Type Parameters
70​
71#### TContext
72​
73`TContext` *extends* `Context`
74​
75### Parameters
76​
77#### queryFn
78​
79(`q`) => `QueryBuilder`\<`TContext`\>
80​
81Query function that defines what data to fetch. Must include `.orderBy()` for setWindow to work.
82​
83#### config
84​
85[`UseLiveInfiniteQueryConfig`](../type-aliases/UseLiveInfiniteQueryConfig.md)\<`TContext`\>
86​
87Configuration including pageSize and getNextPageParam
88​
89#### deps?
90​
91`unknown`[]
92​
93Deprecated array of dependencies that trigger query re-execution when changed
94​
95### Returns
96​
97[`UseLiveInfiniteQueryReturn`](../type-aliases/UseLiveInfiniteQueryReturn.md)\<`TContext`\>
98​
99Object with pages, data, and pagination controls