@livequery/react 1.0.94 → 1.0.95

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.
@@ -9,7 +9,13 @@ function assert(fn, thiss) {
9
9
  export const useCollectionData = (ref, collection_options = {}) => {
10
10
  const { transporter } = useLiveQueryContext();
11
11
  const client = useMemo(() => new CollectionObservable(ref, { transporter, ...collection_options }), [ref]);
12
- const stream = useObservable(client, { options: {}, items: [], has_more: false, loading: false, error: undefined });
12
+ const stream = useObservable(client, {
13
+ options: {},
14
+ items: [],
15
+ has_more: false,
16
+ loading: collection_options.lazy ? false : true,
17
+ error: undefined
18
+ });
13
19
  const { loading, has_more, items, error } = stream;
14
20
  useEffect(() => {
15
21
  try {
@@ -21,11 +27,12 @@ export const useCollectionData = (ref, collection_options = {}) => {
21
27
  useEffect(() => {
22
28
  collection_options.load_all && !loading && has_more && items.length > 0 && client?.fetch_more();
23
29
  }, [loading]);
30
+ const empty = !!(ref && !error && items.length == 0 && !loading);
24
31
  return {
25
32
  ...stream,
26
33
  filters: stream.options,
27
34
  loading: !!stream.loading,
28
- empty: !!(ref && !error && items.length == 0 && loading === false),
35
+ empty,
29
36
  add: assert(client?.add, client),
30
37
  fetch_more: assert(client?.fetch_more, client),
31
38
  filter: assert(client?.filter, client),
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.94",
7
+ "version": "1.0.95",
8
8
  "description": "",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",