@livequery/react 1.0.104 → 1.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,6 +7,7 @@ export type useCollectionDataOptions<T extends LivequeryBaseEntity = LivequeryBa
|
|
|
7
7
|
};
|
|
8
8
|
export type CollectionData<T extends LivequeryBaseEntity> = (CollectionStream<T> & Pick<CollectionObservable<T>, 'add' | 'fetch_more' | 'filter' | 'reload' | 'reset' | 'trigger' | 'update' | '$changes'> & {
|
|
9
9
|
empty: boolean;
|
|
10
|
+
loaded: boolean;
|
|
10
11
|
});
|
|
11
12
|
export type CollectionRef = string | undefined | '' | null | false;
|
|
12
13
|
export declare const useCollectionData: <T extends LivequeryBaseEntity>(ref: CollectionRef, collection_options?: Partial<useCollectionDataOptions<T>>) => CollectionData<T>;
|
|
@@ -30,7 +30,8 @@ export const useCollectionData = (ref, collection_options = {}) => {
|
|
|
30
30
|
return () => subscription.unsubscribe();
|
|
31
31
|
}, [ref, collection_options?.lazy]);
|
|
32
32
|
const client = collection_ref.current;
|
|
33
|
-
const
|
|
33
|
+
const loaded = n > 0;
|
|
34
|
+
const empty = loaded && !stream.loading && stream.items.length == 0;
|
|
34
35
|
const result = {
|
|
35
36
|
...stream,
|
|
36
37
|
error: stream.error,
|
|
@@ -43,7 +44,8 @@ export const useCollectionData = (ref, collection_options = {}) => {
|
|
|
43
44
|
reset: assert(client?.reset, client),
|
|
44
45
|
trigger: assert(client?.trigger, client),
|
|
45
46
|
update: assert(client?.update, client),
|
|
46
|
-
$changes: client?.$changes || new Subject()
|
|
47
|
+
$changes: client?.$changes || new Subject(),
|
|
48
|
+
loaded
|
|
47
49
|
};
|
|
48
50
|
return result;
|
|
49
51
|
};
|