@@ -2,6 +2,7 @@ import { useRef, useSyncExternalStore } from "react"
22import { createLiveQueryCollection } from "@tanstack/db"
33import type {
44 Collection ,
5+ CollectionStatus ,
56 Context ,
67 GetResult ,
78 InitialQueryBuilder ,
@@ -17,6 +18,12 @@ export function useLiveQuery<TContext extends Context>(
1718 state : Map < string | number , GetResult < TContext > >
1819 data : Array < GetResult < TContext > >
1920 collection : Collection < GetResult < TContext > , string | number , { } >
21+ status : CollectionStatus
22+ isLoading : boolean
23+ isReady : boolean
24+ isIdle : boolean
25+ isError : boolean
26+ isCleanedUp : boolean
2027}
2128
2229// Overload 2: Accept config object
@@ -27,6 +34,12 @@ export function useLiveQuery<TContext extends Context>(
2734 state : Map < string | number , GetResult < TContext > >
2835 data : Array < GetResult < TContext > >
2936 collection : Collection < GetResult < TContext > , string | number , { } >
37+ status : CollectionStatus
38+ isLoading : boolean
39+ isReady : boolean
40+ isIdle : boolean
41+ isError : boolean
42+ isCleanedUp : boolean
3043}
3144
3245// Overload 3: Accept pre-created live query collection
@@ -40,6 +53,12 @@ export function useLiveQuery<
4053 state : Map < TKey , TResult >
4154 data : Array < TResult >
4255 collection : Collection < TResult , TKey , TUtils >
56+ status : CollectionStatus
57+ isLoading : boolean
58+ isReady : boolean
59+ isIdle : boolean
60+ isError : boolean
61+ isCleanedUp : boolean
4362}
4463
4564// Implementation - use function overloads to infer the actual collection type
@@ -171,5 +190,13 @@ export function useLiveQuery(
171190 state : snapshot . state ,
172191 data : snapshot . data ,
173192 collection : snapshot . collection ,
193+ status : snapshot . collection . status ,
194+ isLoading :
195+ snapshot . collection . status === `loading` ||
196+ snapshot . collection . status === `initialCommit` ,
197+ isReady : snapshot . collection . status === `ready` ,
198+ isIdle : snapshot . collection . status === `idle` ,
199+ isError : snapshot . collection . status === `error` ,
200+ isCleanedUp : snapshot . collection . status === `cleaned-up` ,
174201 }
175202}
0 commit comments