@livequery/react 1.0.87 → 1.0.90
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.
|
@@ -11,7 +11,7 @@ export declare const useCollectionData: <T extends {
|
|
|
11
11
|
}>(ref: string | undefined | '' | null | 0 | false, collection_options?: Partial<useCollectionDataOptions<T>>) => {
|
|
12
12
|
items: SmartQueryItem<T>[];
|
|
13
13
|
loading: boolean | undefined;
|
|
14
|
-
error: import("@livequery/types").ErrorInfo |
|
|
14
|
+
error: import("@livequery/types").ErrorInfo | undefined;
|
|
15
15
|
has_more: boolean;
|
|
16
16
|
empty: boolean | "" | 0 | null | undefined;
|
|
17
17
|
filters: Partial<QueryOption<T>> | {};
|
|
@@ -8,10 +8,9 @@ function assert(fn, thiss) {
|
|
|
8
8
|
return (fn || (() => { })).bind(thiss);
|
|
9
9
|
}
|
|
10
10
|
export const useCollectionData = (ref, collection_options = {}) => {
|
|
11
|
-
const
|
|
12
|
-
const transporter = lqct;
|
|
11
|
+
const { transporter } = useLiveQueryContext();
|
|
13
12
|
const client = useMemo(() => ref ? new CollectionObservable(ref, { transporter, ...collection_options }) : null, [ref]);
|
|
14
|
-
const data = useObservable(client) || { options: {}, items: [], has_more: false, loading: false, error:
|
|
13
|
+
const data = useObservable(client) || { options: {}, items: [], has_more: false, loading: false, error: undefined };
|
|
15
14
|
const { loading, has_more, error, items, options } = data;
|
|
16
15
|
useEffect(() => {
|
|
17
16
|
try {
|
|
@@ -21,7 +20,7 @@ export const useCollectionData = (ref, collection_options = {}) => {
|
|
|
21
20
|
}
|
|
22
21
|
}, [ref]);
|
|
23
22
|
useEffect(() => {
|
|
24
|
-
|
|
23
|
+
collection_options.load_all && !loading && has_more && items.length > 0 && client?.fetch_more();
|
|
25
24
|
}, [loading]);
|
|
26
25
|
return {
|
|
27
26
|
items,
|
|
@@ -8,7 +8,7 @@ export declare const useDocumentData: <T extends {
|
|
|
8
8
|
}>(ref: string | undefined | '' | null | 0 | false, options?: useDocumentDataOptions) => {
|
|
9
9
|
item: import("@livequery/client").SmartQueryItem<T>;
|
|
10
10
|
loading: boolean | undefined;
|
|
11
|
-
error: import("@livequery/types").ErrorInfo |
|
|
11
|
+
error: import("@livequery/types").ErrorInfo | undefined;
|
|
12
12
|
reload: () => void;
|
|
13
13
|
$changes: import("rxjs").Subject<import("@livequery/types").UpdatedData<T>>;
|
|
14
14
|
};
|
package/build/useObservable.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
export declare const useObservable: <T>(o: Observable<T> | null
|
|
2
|
+
export declare const useObservable: <T>(o: Observable<T> | null) => T | undefined;
|
package/build/useObservable.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
export const useObservable = (o
|
|
3
|
+
export const useObservable = (o) => {
|
|
4
4
|
const [s, ss] = useState();
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
if (o) {
|
|
@@ -10,5 +10,5 @@ export const useObservable = (o, default_value) => {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
}, [o]);
|
|
13
|
-
return s
|
|
13
|
+
return s;
|
|
14
14
|
};
|
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.
|
|
7
|
+
"version": "1.0.90",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "build/index.js",
|
|
10
10
|
"types": "build/index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
34
|
"import": {
|
|
35
|
-
"types": "./build/
|
|
36
|
-
"default": "./build/
|
|
35
|
+
"types": "./build/index.d.ts",
|
|
36
|
+
"default": "./build/index.js"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|