@livequery/react 1.0.103 → 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>;
@@ -12,7 +12,7 @@ export const useCollectionData = (ref, collection_options = {}) => {
12
12
  filters: {},
13
13
  items: [],
14
14
  has_more: false,
15
- loading: collection_options.lazy ? false : true,
15
+ loading: collection_options.lazy ? false : !!ref,
16
16
  error: undefined
17
17
  });
18
18
  const [n, sn] = useState(0);
@@ -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 empty = n > 0 && !stream.loading && stream.items.length == 0;
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
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "url": "https://github.com/livequery/react"
5
5
  },
6
6
  "type": "module",
7
- "version": "1.0.103",
7
+ "version": "1.0.105",
8
8
  "description": "",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",