@triplit/svelte 0.2.33-canary-20250306191454 → 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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @triplit/svelte
2
2
 
3
+ ## 0.2.33-canary-20250308203743
4
+
5
+ ### Patch Changes
6
+
7
+ - @triplit/client@0.7.0-canary-20250308203743
8
+
9
+ ## 0.2.33-canary-20250306235641
10
+
11
+ ### Patch Changes
12
+
13
+ - @triplit/client@0.7.0-canary-20250306235641
14
+
3
15
  ## 0.2.33-canary-20250306191454
4
16
 
5
17
  ### Patch Changes
@@ -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 isInitialFetch = $state(true);
14
+ let fetching = $state(true);
18
15
  let fetchingLocal = $state(true);
19
- let fetchingRemote = $state(client.connectionStatus !== 'CLOSED');
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
- .isFirstTimeFetchingQuery($state.snapshot(query))
26
- .then((isFirstFetch) => {
27
- isInitialFetch = isFirstFetch;
28
- });
29
- const unsub = client.onConnectionStatusChange((status) => {
30
- if (status === 'CLOSING' || status === 'CLOSED') {
31
- fetchingRemote = false;
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-20250306191454",
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-20250306191454"
32
+ "@triplit/client": "^0.7.0-canary-20250308203743"
33
33
  },
34
34
  "devDependencies": {
35
- "@sveltejs/package": "^2.3.5",
36
- "@tsconfig/svelte": "^5.0.2",
37
- "svelte": "^5.0.0-next.255",
38
- "svelte-check": "^4.0.2",
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
  },