@tanstack/react-query-persist-client 4.10.1 → 4.12.0
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/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-query-persist-client",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.12.0",
|
|
4
|
+
"description": "React bindings to work with persisters in TanStack/react-query",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "tanstack/query",
|
|
@@ -28,16 +28,24 @@
|
|
|
28
28
|
"src"
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@
|
|
31
|
+
"@types/react": "^18.0.14",
|
|
32
|
+
"@types/react-dom": "^18.0.5",
|
|
33
|
+
"react": "^18.2.0",
|
|
34
|
+
"react-17": "npm:react@^17.0.2",
|
|
35
|
+
"react-dom": "^18.2.0",
|
|
36
|
+
"react-dom-17": "npm:react-dom@^17.0.2",
|
|
37
|
+
"@tanstack/react-query": "4.12.0"
|
|
32
38
|
},
|
|
33
39
|
"dependencies": {
|
|
34
|
-
"@tanstack/query-persist-client-core": "4.
|
|
40
|
+
"@tanstack/query-persist-client-core": "4.12.0"
|
|
35
41
|
},
|
|
36
42
|
"peerDependencies": {
|
|
37
|
-
"@tanstack/react-query": "4.
|
|
43
|
+
"@tanstack/react-query": "4.12.0"
|
|
38
44
|
},
|
|
39
45
|
"scripts": {
|
|
40
46
|
"clean": "rm -rf ./build",
|
|
41
|
-
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src"
|
|
47
|
+
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
|
|
48
|
+
"test:jest": "../../node_modules/.bin/jest --config ./jest.config.ts",
|
|
49
|
+
"test:dev": "pnpm run test:jest --watch"
|
|
42
50
|
}
|
|
43
51
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createQueryClient, sleep } from './utils'
|
|
2
|
-
import type {
|
|
3
|
-
PersistedClient,
|
|
4
|
-
Persister,
|
|
5
|
-
} from '@tanstack/query-persist-client-core'
|
|
6
|
-
import { persistQueryClientSubscribe } from '@tanstack/query-persist-client-core'
|
|
7
|
-
|
|
8
|
-
const createMockPersister = (): Persister => {
|
|
9
|
-
let storedState: PersistedClient | undefined
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
async persistClient(persistClient: PersistedClient) {
|
|
13
|
-
storedState = persistClient
|
|
14
|
-
},
|
|
15
|
-
async restoreClient() {
|
|
16
|
-
await sleep(10)
|
|
17
|
-
return storedState
|
|
18
|
-
},
|
|
19
|
-
removeClient() {
|
|
20
|
-
storedState = undefined
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe('persistQueryClientSubscribe', () => {
|
|
26
|
-
test('should persist mutations', async () => {
|
|
27
|
-
const queryClient = createQueryClient()
|
|
28
|
-
|
|
29
|
-
const persister = createMockPersister()
|
|
30
|
-
|
|
31
|
-
const unsubscribe = persistQueryClientSubscribe({
|
|
32
|
-
queryClient,
|
|
33
|
-
persister,
|
|
34
|
-
dehydrateOptions: { shouldDehydrateMutation: () => true },
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
queryClient.getMutationCache().build(queryClient, {
|
|
38
|
-
mutationFn: async (text: string) => text,
|
|
39
|
-
variables: 'todo',
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const result = await persister.restoreClient()
|
|
43
|
-
|
|
44
|
-
expect(result?.clientState.mutations).toHaveLength(1)
|
|
45
|
-
|
|
46
|
-
unsubscribe()
|
|
47
|
-
})
|
|
48
|
-
})
|