@powersync/react 0.0.0-dev-20250916075127 → 0.0.0-dev-20250922105207
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.
|
@@ -27,51 +27,20 @@ export const useWatchedQuery = (options) => {
|
|
|
27
27
|
return watch;
|
|
28
28
|
}
|
|
29
29
|
const [watchedQuery, setWatchedQuery] = React.useState(createWatchedQuery);
|
|
30
|
-
const disposePendingUpdateListener = React.useRef(null);
|
|
31
30
|
React.useEffect(() => {
|
|
32
31
|
watchedQuery?.close();
|
|
33
|
-
|
|
34
|
-
setWatchedQuery(newQuery);
|
|
35
|
-
return () => {
|
|
36
|
-
disposePendingUpdateListener.current?.();
|
|
37
|
-
newQuery?.close();
|
|
38
|
-
};
|
|
32
|
+
setWatchedQuery(createWatchedQuery);
|
|
39
33
|
}, [powerSync, active]);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* just before the `isFetching` status is updated.
|
|
53
|
-
*/
|
|
54
|
-
if (queryChanged) {
|
|
55
|
-
// Keep track of this pending operation
|
|
56
|
-
watchedQuery?.updateSettings({
|
|
57
|
-
query,
|
|
58
|
-
throttleMs: hookOptions.throttleMs,
|
|
59
|
-
reportFetching: hookOptions.reportFetching
|
|
60
|
-
});
|
|
61
|
-
// This could have been called multiple times, clear any old listeners.
|
|
62
|
-
disposePendingUpdateListener.current?.();
|
|
63
|
-
disposePendingUpdateListener.current = watchedQuery?.registerListener({
|
|
64
|
-
settingsWillUpdate: () => {
|
|
65
|
-
// We'll use the fact that we have a listener at all as an indication
|
|
66
|
-
disposePendingUpdateListener.current?.();
|
|
67
|
-
disposePendingUpdateListener.current = null;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
const shouldReportCurrentlyFetching = (hookOptions.reportFetching ?? true) && !!disposePendingUpdateListener.current;
|
|
72
|
-
const result = useNullableWatchedQuerySubscription(watchedQuery);
|
|
73
|
-
return {
|
|
74
|
-
...result,
|
|
75
|
-
isFetching: result?.isFetching || shouldReportCurrentlyFetching
|
|
76
|
-
};
|
|
34
|
+
// Indicates that the query will be re-fetched due to a change in the query.
|
|
35
|
+
// Used when `isFetching` hasn't been set to true yet due to React execution.
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (queryChanged) {
|
|
38
|
+
watchedQuery?.updateSettings({
|
|
39
|
+
query,
|
|
40
|
+
throttleMs: hookOptions.throttleMs,
|
|
41
|
+
reportFetching: hookOptions.reportFetching
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [queryChanged]);
|
|
45
|
+
return useNullableWatchedQuerySubscription(watchedQuery);
|
|
77
46
|
};
|
|
@@ -47,7 +47,7 @@ export const constructCompatibleQuery = (query, parameters = [], options) => {
|
|
|
47
47
|
execute: () => query.execute()
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
}, [query, powerSync
|
|
50
|
+
}, [query, powerSync]);
|
|
51
51
|
const queryChanged = checkQueryChanged(parsedQuery, options);
|
|
52
52
|
return {
|
|
53
53
|
parsedQuery,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/react",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20250922105207",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://docs.powersync.com",
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@powersync/common": "0.0.0-dev-
|
|
27
|
+
"@powersync/common": "0.0.0-dev-20250922105207",
|
|
28
28
|
"react": "*"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -35,9 +35,8 @@
|
|
|
35
35
|
"react": "18.3.1",
|
|
36
36
|
"react-dom": "18.3.1",
|
|
37
37
|
"react-error-boundary": "^4.1.0",
|
|
38
|
-
"@powersync/common": "0.0.0-dev-
|
|
39
|
-
"@powersync/web": "0.0.0-dev-
|
|
40
|
-
"@powersync/drizzle-driver": "0.6.0"
|
|
38
|
+
"@powersync/common": "0.0.0-dev-20250922105207",
|
|
39
|
+
"@powersync/web": "0.0.0-dev-20250922105207"
|
|
41
40
|
},
|
|
42
41
|
"scripts": {
|
|
43
42
|
"build": "tsc -b",
|