@triplit/svelte 0.2.33-canary-20250306235641 → 0.2.33-canary-20250308203743
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.
- package/CHANGELOG.md +6 -0
- package/dist/index.svelte.js +10 -44
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
package/dist/index.svelte.js
CHANGED
@@ -10,54 +10,20 @@
|
|
10
10
|
* @returns An object containing the fetching state, the result of the query, any error that occurred, and a function to update the query
|
11
11
|
*/
|
12
12
|
export function useQuery(client, query, options) {
|
13
|
-
// & {
|
14
|
-
// updateQuery: (query: Q) => void;
|
15
|
-
// }
|
16
13
|
let results = $state(undefined);
|
17
|
-
let
|
14
|
+
let fetching = $state(true);
|
18
15
|
let fetchingLocal = $state(true);
|
19
|
-
let fetchingRemote = $state(
|
20
|
-
let fetching = $derived(fetchingLocal || (isInitialFetch && fetchingRemote));
|
16
|
+
let fetchingRemote = $state(false);
|
21
17
|
let error = $state(undefined);
|
22
|
-
let hasResponseFromServer = false;
|
23
18
|
$effect(() => {
|
24
|
-
client
|
25
|
-
.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
if (status === 'OPEN' && hasResponseFromServer === false) {
|
35
|
-
fetchingRemote = true;
|
36
|
-
return;
|
37
|
-
}
|
38
|
-
}, true);
|
39
|
-
return () => {
|
40
|
-
unsub();
|
41
|
-
};
|
42
|
-
});
|
43
|
-
$effect(() => {
|
44
|
-
const unsubscribe = client.subscribe($state.snapshot(query), (localResults) => {
|
45
|
-
fetchingLocal = false;
|
46
|
-
error = undefined;
|
47
|
-
results = localResults;
|
48
|
-
}, (error) => {
|
49
|
-
fetchingLocal = false;
|
50
|
-
error = error;
|
51
|
-
}, {
|
52
|
-
...(options ?? {}),
|
53
|
-
onRemoteFulfilled: () => {
|
54
|
-
hasResponseFromServer = true;
|
55
|
-
fetchingRemote = false;
|
56
|
-
},
|
57
|
-
});
|
58
|
-
return () => {
|
59
|
-
unsubscribe();
|
60
|
-
};
|
19
|
+
const unsub = client.subscribeWithStatus(query, (newVal) => {
|
20
|
+
results = newVal.results;
|
21
|
+
fetching = newVal.fetching;
|
22
|
+
fetchingLocal = newVal.fetchingLocal;
|
23
|
+
fetchingRemote = newVal.fetchingRemote;
|
24
|
+
error = newVal.error;
|
25
|
+
}, options);
|
26
|
+
return unsub;
|
61
27
|
});
|
62
28
|
return {
|
63
29
|
get fetching() {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@triplit/svelte",
|
3
3
|
"packageManager": "yarn@3.4.1",
|
4
|
-
"version": "0.2.33-canary-
|
4
|
+
"version": "0.2.33-canary-20250308203743",
|
5
5
|
"source": "./src/index.svelte.ts",
|
6
6
|
"main": "./dist/index.svelte.js",
|
7
7
|
"module": "./dist/index.svelte.js",
|
@@ -29,13 +29,13 @@
|
|
29
29
|
"/dist"
|
30
30
|
],
|
31
31
|
"dependencies": {
|
32
|
-
"@triplit/client": "^0.7.0-canary-
|
32
|
+
"@triplit/client": "^0.7.0-canary-20250308203743"
|
33
33
|
},
|
34
34
|
"devDependencies": {
|
35
|
-
"@sveltejs/package": "^2.3.
|
36
|
-
"@tsconfig/svelte": "^5.0.
|
37
|
-
"svelte": "^5.
|
38
|
-
"svelte-check": "^4.
|
35
|
+
"@sveltejs/package": "^2.3.10",
|
36
|
+
"@tsconfig/svelte": "^5.0.4",
|
37
|
+
"svelte": "^5.22.6",
|
38
|
+
"svelte-check": "^4.1.5",
|
39
39
|
"tslib": "^2.6.2",
|
40
40
|
"typescript": "^5.2.2"
|
41
41
|
},
|