tanstack-query-callbacks 0.1.0-beta.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +72 -1
  2. package/package.json +12 -10
package/README.md CHANGED
@@ -1,3 +1,74 @@
1
1
  # tanstack-query-callbacks
2
2
 
3
- 🚧
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![bundle][bundle-src]][bundle-href]
6
+
7
+ Use callbacks of query in the usual way, as before.
8
+
9
+ The tanstack/query has removed `onSuccess`, `onError` and `onSettled` from useQuery in v5. You can find more information in the [RFC](https://github.com/TanStack/query/discussions/5279).
10
+
11
+ ## Instanll
12
+
13
+ ```shell
14
+ // use npm
15
+ npm install tanstack-query-callbacks
16
+
17
+ // use pnpm
18
+ pnpm add tanstack-query-callbacks
19
+ ```
20
+
21
+ ## Usage (Vue)
22
+
23
+ ```vue
24
+ <script setup lang=ts>
25
+ import { useQuery } from '@tanstack/vue-query'
26
+ import { useQueryCallbacks } from 'tanstack-query-callbacks/vue'
27
+ const queryKey = ['foo']
28
+ const query = useQuery(queryKey, () => Promise.resolve('bar'))
29
+ useQueryCallbacks({
30
+ queryKey,
31
+ onSuccess: (data) => {
32
+ console.log('success', data)
33
+ },
34
+ onError: (err) => {
35
+ console.error('error', err)
36
+ },
37
+ onSettled: (data, err) => {
38
+ console.log('settled', { data, err })
39
+ }
40
+ })
41
+ </script>
42
+ ```
43
+
44
+ ## Usage (React)
45
+
46
+ ```ts
47
+ import { useQuery } from '@tanstack/react-query'
48
+ import { useQueryCallbacks } from 'tanstack-query-callbacks/react'
49
+
50
+ const queryKey = ['foo']
51
+ const query = useQuery(queryKey, () => Promise.resolve('bar'))
52
+
53
+ useQueryCallbacks({
54
+ queryKey,
55
+ onSuccess: (data) => {
56
+ console.log('success', data)
57
+ },
58
+ onError: (err) => {
59
+ console.error('error', err)
60
+ },
61
+ onSettled: (data, err) => {
62
+ console.log('settled', { data, err })
63
+ }
64
+ })
65
+ ```
66
+
67
+ <!-- Link Resources -->
68
+
69
+ [npm-version-src]: https://img.shields.io/npm/v/tanstack-query-callbacks?style=flat&colorA=18181B&colorB=F0DB4F
70
+ [npm-version-href]: https://npmjs.com/package/tanstack-query-callbacks
71
+ [npm-downloads-src]: https://img.shields.io/npm/dm/tanstack-query-callbacks?style=flat&colorA=18181B&colorB=F0DB4F
72
+ [npm-downloads-href]: https://npmjs.com/package/tanstack-query-callbacks
73
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/tanstack-query-callbacks?style=flat&colorA=18181B&colorB=F0DB4F
74
+ [bundle-href]: https://bundlephobia.com/result?p=tanstack-query-callbacks
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tanstack-query-callbacks",
3
3
  "type": "module",
4
- "version": "0.1.0-beta.0",
4
+ "version": "0.1.0",
5
5
  "packageManager": "pnpm@8.10.0",
6
6
  "author": "zhong666 <hi@zhong666.me>",
7
7
  "license": "MIT",
@@ -45,11 +45,11 @@
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@tanstack/query-core": "^5.*",
48
- "@tanstack/vue-query": "^5.*",
49
48
  "@tanstack/react-query": "^5.*",
49
+ "@tanstack/vue-query": "^5.*",
50
50
  "@vue/composition-api": "^1.1.0",
51
- "vue": "^2.6.12 || ^3.2.0",
52
- "react": "^18.0.0"
51
+ "react": "^18.0.0",
52
+ "vue": "^2.6.12 || ^3.2.0"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@tanstack/vue-query": {
@@ -72,28 +72,30 @@
72
72
  "@aa900031/eslint-config": "^1.0.1",
73
73
  "@release-it/conventional-changelog": "^7.0.2",
74
74
  "@tanstack/query-core": "^5.14.2",
75
- "@tanstack/vue-query": "^5.14.2",
76
75
  "@tanstack/react-query": "^5.14.2",
77
- "@testing-library/vue": "^8.0.1",
76
+ "@tanstack/vue-query": "^5.14.2",
78
77
  "@testing-library/react": "14.1.2",
78
+ "@testing-library/vue": "^8.0.1",
79
79
  "@tsconfig/node18": "^18.2.2",
80
80
  "@types/node": "^18.18.7",
81
81
  "@types/react": "^18.2.45",
82
82
  "@types/react-dom": "^18.2.18",
83
+ "@vitest/coverage-istanbul": "^1.1.0",
84
+ "@vitest/ui": "^1.1.0",
83
85
  "conventional-changelog-unjs": "^0.1.0",
84
86
  "eslint": "^8.52.0",
85
87
  "happy-dom": "^12.10.3",
88
+ "react": "^18.2.0",
89
+ "react-dom": "^18.2.0",
86
90
  "release-it": "^16.2.1",
87
91
  "typescript": "^5.2.2",
88
92
  "unbuild": "^2.0.0",
89
93
  "vitest": "^1.1.0",
90
- "vue": "^3.3.13",
91
- "react": "^18.2.0",
92
- "react-dom": "^18.2.0"
94
+ "vue": "^3.3.13"
93
95
  },
94
96
  "scripts": {
95
97
  "build": "unbuild",
96
- "test": "vitest run",
98
+ "test": "vitest run --coverage",
97
99
  "dev:test": "vitest",
98
100
  "release": "release-it --ci",
99
101
  "lint": "eslint . --cache --cache-location ./node_modules/.cache/eslint"