@tanstack/solid-query-persist-client 5.94.5 → 6.0.0-alpha.1
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/build/dev.cjs +1153 -7
- package/build/dev.js +1154 -8
- package/build/index.cjs +1153 -7
- package/build/index.js +1154 -8
- package/package.json +11 -7
- package/src/PersistQueryClientProvider.tsx +29 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-query-persist-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.1",
|
|
4
4
|
"description": "Solid.js bindings to work with persisters in TanStack/solid-query",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,20 +46,24 @@
|
|
|
46
46
|
"!src/__tests__"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@tanstack/query-persist-client-core": "5.
|
|
49
|
+
"@tanstack/query-persist-client-core": "5.92.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
+
"@babel/core": "^7.28.0",
|
|
53
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
52
54
|
"@solidjs/testing-library": "^0.8.10",
|
|
55
|
+
"@solidjs/web": "2.0.0-beta.4",
|
|
56
|
+
"babel-preset-solid": "2.0.0-beta.4",
|
|
53
57
|
"npm-run-all2": "^5.0.0",
|
|
54
|
-
"solid-js": "
|
|
58
|
+
"solid-js": "2.0.0-beta.4",
|
|
55
59
|
"tsup-preset-solid": "^2.2.0",
|
|
56
|
-
"vite-plugin-solid": "
|
|
60
|
+
"vite-plugin-solid": "3.0.0-next.2",
|
|
57
61
|
"@tanstack/query-test-utils": "0.0.0",
|
|
58
|
-
"@tanstack/solid-query": "
|
|
62
|
+
"@tanstack/solid-query": "6.0.0-alpha.1"
|
|
59
63
|
},
|
|
60
64
|
"peerDependencies": {
|
|
61
|
-
"solid-js": "
|
|
62
|
-
"@tanstack/solid-query": "^
|
|
65
|
+
"solid-js": ">=2.0.0-beta.0 <3.0.0",
|
|
66
|
+
"@tanstack/solid-query": "^6.0.0-alpha.1"
|
|
63
67
|
},
|
|
64
68
|
"scripts": {
|
|
65
69
|
"clean": "premove ./build ./coverage ./dist-ts",
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
persistQueryClientSubscribe,
|
|
4
4
|
} from '@tanstack/query-persist-client-core'
|
|
5
5
|
import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
|
|
6
|
-
import {
|
|
6
|
+
import { IsRestoringContext, QueryClientProvider } from '@tanstack/solid-query'
|
|
7
7
|
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
|
|
8
8
|
import type { OmitKeyof, QueryClientProviderProps } from '@tanstack/solid-query'
|
|
9
9
|
import type { JSX } from 'solid-js'
|
|
@@ -18,35 +18,45 @@ export const PersistQueryClientProvider = (
|
|
|
18
18
|
props: PersistQueryClientProviderProps,
|
|
19
19
|
): JSX.Element => {
|
|
20
20
|
const [isRestoring, setIsRestoring] = createSignal(true)
|
|
21
|
+
let didRestore = false
|
|
21
22
|
|
|
22
23
|
const options = createMemo(() => ({
|
|
23
24
|
...props.persistOptions,
|
|
24
25
|
queryClient: props.client,
|
|
25
26
|
}))
|
|
26
27
|
|
|
27
|
-
createEffect(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
createEffect(
|
|
29
|
+
() => {
|
|
30
|
+
const opts = options()
|
|
31
|
+
if (!didRestore) {
|
|
32
|
+
didRestore = true
|
|
33
|
+
persistQueryClientRestore(opts)
|
|
34
|
+
.then(() => props.onSuccess?.())
|
|
35
|
+
.catch(() => props.onError?.())
|
|
36
|
+
.finally(() => {
|
|
37
|
+
setIsRestoring(false)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
() => {},
|
|
42
|
+
)
|
|
36
43
|
|
|
37
|
-
createEffect(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
createEffect(
|
|
45
|
+
() => {
|
|
46
|
+
let unsubscribe = () => {}
|
|
47
|
+
if (!isRestoring()) {
|
|
48
|
+
unsubscribe = persistQueryClientSubscribe(options())
|
|
49
|
+
}
|
|
50
|
+
onCleanup(() => unsubscribe())
|
|
51
|
+
},
|
|
52
|
+
() => {},
|
|
53
|
+
)
|
|
44
54
|
|
|
45
55
|
return (
|
|
46
56
|
<QueryClientProvider client={props.client}>
|
|
47
|
-
<
|
|
57
|
+
<IsRestoringContext value={isRestoring}>
|
|
48
58
|
{props.children}
|
|
49
|
-
</
|
|
59
|
+
</IsRestoringContext>
|
|
50
60
|
</QueryClientProvider>
|
|
51
61
|
)
|
|
52
62
|
}
|