vue-asyncx 1.7.0 → 1.8.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/README.md +110 -265
- package/dist/vue-asyncx.d.ts +1 -0
- package/dist/vue-asyncx.js +158 -117
- package/dist/vue-asyncx.umd.cjs +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
优雅好用的异步函数/数据管理工具
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
1
5
|
## 特性
|
|
2
6
|
|
|
3
|
-
- 效率+:异步相关样板代码减少
|
|
4
|
-
- 效率+:自动处理异步操作的乱序响应
|
|
7
|
+
- 效率+:异步相关样板代码减少40%+
|
|
5
8
|
- 可读+:异步操作命名指向明确、风格统一
|
|
6
|
-
- 可读+:易于写出符合“干净架构”理念的函数
|
|
7
9
|
- 质量+:全 TS 支持 + 100% 单元测试
|
|
10
|
+
- 维护+:易于写出符合“干净架构”理念的函数
|
|
8
11
|
|
|
9
12
|
## 安装
|
|
10
13
|
|
|
@@ -12,126 +15,102 @@
|
|
|
12
15
|
pnpm i vue-asyncx
|
|
13
16
|
```
|
|
14
17
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
### useAsync 异步函数
|
|
18
|
-
|
|
19
|
-
当需要执行一个异步函数,可以将要执行的异步函数传入 `useAsync` 中,得到
|
|
20
|
-
|
|
21
|
-
- 一个异步函数的包裹函数
|
|
22
|
-
- 一个记录异步函数执行 `loading` 响应式数据
|
|
23
|
-
- 等等
|
|
18
|
+
## 快速开始
|
|
24
19
|
|
|
25
20
|
```ts
|
|
26
|
-
import {
|
|
21
|
+
import { getUserApi } from './api'
|
|
22
|
+
import { useAsyncData } from '../dist/vue-asyncx'
|
|
27
23
|
|
|
28
24
|
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
user,
|
|
26
|
+
queryUserLoading,
|
|
27
|
+
queryUser,
|
|
28
|
+
} = useAsyncData('user', getUserApi)
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
queryUser('Mike')
|
|
34
31
|
```
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
当需要异步数据 `user` 时,只需要传入数据的变量名和获取数据的异步函数即可。`useAsyncData` 会自动处理与异步函数相关的 `loading`, `data`, `function`、`error` 等状态。
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
import { useAsync } from 'vue-asyncx'
|
|
35
|
+
## 约定带来效率
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
sum,
|
|
43
|
-
sumLoading
|
|
44
|
-
} = useAsync('sum', async (a: number, b: number) => a + b)
|
|
37
|
+
与 [`useRequest`](https://ahooks.js.org/hooks/use-request/index) 返回固定的 `data`、`loading`、`error` 不同,`useAsyncData` 将关联的函数、变量统一命名:
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
- `user`:由异步函数更新的数据 `data`
|
|
40
|
+
- `queryUser`:更新 `user` 的异步函数
|
|
41
|
+
- `queryUserLoading`:调用 `queryUser` 时的 `loading` 状态
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
刚接触可能有些不习惯,但这种方式带来可读性和效率的双重提升,在大型项目、多人团队中尤为明显。
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+
代码中看到 `queryUserLoading` 变量,就知道它和 `user` 变量以及 `queryUser` 函数有关。
|
|
52
46
|
|
|
53
|
-
|
|
47
|
+

|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
并且这一切,都可以自动提示。
|
|
56
50
|
|
|
57
|
-
|
|
51
|
+
## 用法
|
|
58
52
|
|
|
59
|
-
|
|
53
|
+
### 立即执行
|
|
60
54
|
|
|
61
|
-
|
|
55
|
+
默认情况下,异步函数需要手动调用,可以设置 `options.immediate = true` 自动触发异步函数。
|
|
62
56
|
|
|
63
57
|
```ts
|
|
64
|
-
import { getUserById } from '@/api'
|
|
65
|
-
import { useAsyncData } from 'vue-asyncx'
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 调用 useAsyncData('user', ...),
|
|
69
|
-
* user、queryUserLoading、queryUser 自动提示
|
|
70
|
-
*/
|
|
71
58
|
const {
|
|
72
59
|
user,
|
|
73
|
-
queryUserLoading
|
|
74
|
-
|
|
75
|
-
} = useAsyncData('user', () => getUserById('1'), { immediate: true })
|
|
60
|
+
queryUserLoading
|
|
61
|
+
} = useAsyncData('user', getUserApi, { immediate: true })
|
|
76
62
|
```
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
- 数据命名:页面需要使用异步数据 user => `useAsyncData('user', `
|
|
80
|
-
- 数据获取:user 数据来自 getUserById 接口 => `useAsyncData('user', () => getUserById('1')`
|
|
81
|
-
- 触发获取:进入页面后需要立即获取 user 数据 `useAsyncData('user', () => getUserById('1'), { immediate: true })`
|
|
64
|
+
### watch 执行
|
|
82
65
|
|
|
83
|
-
|
|
66
|
+
除了 `immediate`,`useAsyncData` 还完整支持 [vue watch](https://vuejs.org/api/reactivity-core.html#watch)
|
|
84
67
|
|
|
85
|
-
|
|
86
|
-
- 获取 `user` 的函数被自动命名为 `queryUser`
|
|
87
|
-
- 调用 `queryUser` 时的加载状态自动关联到 `queryUserLoading`
|
|
68
|
+
#### `options.watch` 配置 watch source
|
|
88
69
|
|
|
89
|
-
|
|
70
|
+
```ts
|
|
71
|
+
import { getUserApi } from './api'
|
|
72
|
+
import { useAsyncData } from '../dist/vue-asyncx'
|
|
90
73
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
>
|
|
94
|
-
> `useAsync` 关注异步函数,不关注需要长久保留结果值。例如 `submit`、`confirm` 等操作
|
|
95
|
-
> `useAsyncData` 则关注异步数据,异步函数则是数据的获取方式
|
|
74
|
+
const props = defineProps<{
|
|
75
|
+
userId: string;
|
|
76
|
+
}>();
|
|
96
77
|
|
|
97
|
-
|
|
78
|
+
const { user } = useAsyncData('user', () => getUserApi(props.userId), {
|
|
79
|
+
watch: () => props.userId,
|
|
80
|
+
immediate: true
|
|
81
|
+
})
|
|
82
|
+
```
|
|
98
83
|
|
|
99
|
-
|
|
84
|
+
`useAsyncData` 会立即执行,并在每次 `props.userId` 变化时执行。
|
|
100
85
|
|
|
101
|
-
|
|
102
|
-
- 通过 `options.watch` 配置 watch source
|
|
103
|
-
- 通过 `options.watchOptions` 配置 watch 的其它 options
|
|
86
|
+
上面的写法等价于:
|
|
104
87
|
|
|
105
|
-
|
|
88
|
+
```ts
|
|
89
|
+
const { user, queryUser } = useAsyncData('user', () => getUserApi(props.userId))
|
|
90
|
+
watch(() => props.userId, () => queryUser(), { immediate: true })
|
|
91
|
+
```
|
|
106
92
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} = useAsyncData('user', () => getUserById(props.id), {
|
|
113
|
-
watch: () => props.id, // 此处用 props 举例,支持所有 vue watch source 的用法
|
|
114
|
-
immediate: true,
|
|
93
|
+
#### `options.watchOptions` 配置 watch options
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const { user } = useAsyncData('user', () => getUserApi(props.userId), {
|
|
97
|
+
watch: () => props.userId,
|
|
115
98
|
watchOptions: {
|
|
116
|
-
once: true // 此处用 once 举例,支持所有 vue watch options 内的配置
|
|
117
|
-
// 这里也可以配置 immediate,与上一层的 immediate 效果一致,优先级更高
|
|
99
|
+
once: true, // 此处用 once 举例,支持所有 vue watch options 内的配置
|
|
118
100
|
}
|
|
119
101
|
})
|
|
120
102
|
```
|
|
121
103
|
|
|
122
|
-
|
|
104
|
+
> 注:`options.watchOptions.immediate` 优先级高于 `options.immediate`
|
|
123
105
|
|
|
124
|
-
|
|
106
|
+
#### `options.watchOptions.handlerCreator` 配置 watch handler
|
|
125
107
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```js
|
|
108
|
+
```ts
|
|
129
109
|
const {
|
|
130
|
-
user,
|
|
131
|
-
queryUserLoading,
|
|
110
|
+
user,
|
|
132
111
|
queryUser
|
|
133
|
-
} = useAsyncData('user', (
|
|
134
|
-
watch: () => props.
|
|
112
|
+
} = useAsyncData('user', (userId) => getUserApi(userId), {
|
|
113
|
+
watch: () => props.userId,
|
|
135
114
|
immediate: true,
|
|
136
115
|
watchOptions: {
|
|
137
116
|
// fn 等价于 queryUser
|
|
@@ -147,130 +126,20 @@ const {
|
|
|
147
126
|
})
|
|
148
127
|
```
|
|
149
128
|
|
|
150
|
-
###
|
|
151
|
-
|
|
152
|
-
除了 `loading`,`useAsync` 与 `useAsyncData` 还支持记录调用的 `error` 与 `arguments`,默认状态下,它们的命名是:
|
|
153
|
-
|
|
154
|
-
```js
|
|
155
|
-
const {
|
|
156
|
-
methodError,
|
|
157
|
-
methodArguments,
|
|
158
|
-
} = useAsync(() => {})
|
|
159
|
-
|
|
160
|
-
const {
|
|
161
|
-
queryDataError,
|
|
162
|
-
queryDataArguments
|
|
163
|
-
} = useAsyncData(() => {})
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
与之前例子一致,当自定义命名时,结果随之改变:
|
|
167
|
-
|
|
168
|
-
```js
|
|
169
|
-
const {
|
|
170
|
-
confirmError,
|
|
171
|
-
confirmArguments,
|
|
172
|
-
} = useAsync('confirm', () => {})
|
|
173
|
-
|
|
174
|
-
const {
|
|
175
|
-
queryUserError,
|
|
176
|
-
queryUserArguments
|
|
177
|
-
} = useAsyncData('user', () => {})
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
`error`
|
|
181
|
-
- **最后一次**调用 fn,**且**调用结果失败
|
|
182
|
-
- 记录异步 fn 的 reject 内容
|
|
183
|
-
- 记录同步 fn 的 throw 内容
|
|
184
|
-
- **新一次**调用开始后,`error` 自动置空
|
|
129
|
+
### 初始数据配置
|
|
185
130
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
```js
|
|
193
|
-
// 使用 useAsync,没有 user 变量
|
|
194
|
-
const {
|
|
195
|
-
queryUser,
|
|
196
|
-
queryUserLoading,
|
|
197
|
-
} = useAsync('queryUser', () => {})
|
|
198
|
-
|
|
199
|
-
// 或者,使用 useAsyncData
|
|
200
|
-
const {
|
|
201
|
-
user,
|
|
202
|
-
queryUser,
|
|
203
|
-
queryUserLoading
|
|
204
|
-
} = useAsyncData('user', () => {})
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
`queryUser` 是个异步函数,由于异步操作时间不定,多次调用情况下会出现乱序响应,考虑下列的时间线顺序:
|
|
208
|
-
|
|
209
|
-
- **首次调用** `queryUser`,记做 `queryUser1`
|
|
210
|
-
- `queryUser1` 未结束,**再次调用** `queryUser`,记做 `queryUser2`
|
|
211
|
-
- `queryUser2` 先结束
|
|
212
|
-
- `queryUser1` 后结束
|
|
213
|
-
|
|
214
|
-
即:**依次调用 `queryUser1` 和 `queryUser2`,但 `queryUser2` 先于 `queryUser1` 结束**。这种场景很常见,专门处理很麻烦。
|
|
215
|
-
|
|
216
|
-
而使用 `useAsync` 和 `useAsyncData`,你无需再考虑这类问题,方法会自动帮你处理。
|
|
217
|
-
|
|
218
|
-
以上述例子举例:
|
|
219
|
-
|
|
220
|
-
- `queryUser1` 开始时,`queryUserLoading.value` 为 `true`
|
|
221
|
-
- **`queryUser2` 结束时**,`queryUserLoading.value` 为 `false`
|
|
222
|
-
|
|
223
|
-
对于 `useAsyncData`,`queryUser` 对应的 `user` 数据:
|
|
224
|
-
|
|
225
|
-
- `user.value` 将始终以 `queryUser2` 的结果为准(取**最晚的调用**产生的结果)
|
|
226
|
-
- 即使 `queryUser1` 产生结果的时间更晚,但 `queryUser1` 的结果不会更新到 `user.value` 上
|
|
227
|
-
- `queryUser1` 的结果会被自动舍弃,因为这是一个“过期的”数据
|
|
228
|
-
|
|
229
|
-
> 另一种处理重复调用的方式是不允许在上次调用未结束时再次调用
|
|
230
|
-
>
|
|
231
|
-
> 由于 `useAsync` 和 `useAsyncData` 提供了响应式的 `loading`,对于常用组件库,向按钮传入 `loading` 状态或在 `disabled` 属性中添加 `loading` 判断即可轻松避免
|
|
232
|
-
>
|
|
233
|
-
> 此处讨论的是因数据源变动导致异步数据需要刷新的场景,比如 `userId` 短时间从 `1` 切换到 `2`,`user` 数据需要做对应刷新
|
|
234
|
-
|
|
235
|
-
### 数据过期
|
|
236
|
-
|
|
237
|
-
> 过期数据标注是 `useAsyncData` 独有功能
|
|
238
|
-
|
|
239
|
-
```js
|
|
240
|
-
const {
|
|
241
|
-
user,
|
|
242
|
-
queryUser,
|
|
243
|
-
queryUserError,
|
|
244
|
-
userExpired
|
|
245
|
-
} = useAsyncData('user', () => {})
|
|
131
|
+
```ts
|
|
132
|
+
const { user } = useAsyncData('user', getUserApi, {
|
|
133
|
+
// 未配置时,user 首次调用前为 undefined
|
|
134
|
+
initialData: {}
|
|
135
|
+
})
|
|
246
136
|
```
|
|
247
137
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
- 首次调用 `queryUser`,记做 `queryUser1`
|
|
251
|
-
- `queryUser1` 未结束,再次调用 `queryUser`,记做 `queryUser2`
|
|
252
|
-
- `queryUser2` 先结束,**但发生报错**
|
|
253
|
-
- `queryUser1` 后结束
|
|
254
|
-
|
|
255
|
-
此时:
|
|
256
|
-
- `queryUser2` 的错误会被记录到 `queryUserError.value` 上
|
|
257
|
-
- `queryUser1` 的结果**会被更新到** `user.value` 上
|
|
258
|
-
- `userExpired.value` 会被设置为 `true`,表明当前的 `user.value` 是个过期数据(因为 `user.value` 来自`queryUser1`,而最新的结果是 `queryUser2` 的报错)
|
|
259
|
-
|
|
260
|
-
> 大多数情况下,无需考虑 `userExpired.value` 的问题,因为它只会在 `queryUserError.value` 出现时出现,优先处理 `queryUserError.value` 往往是更好的做法
|
|
138
|
+
### 异步函数执行过程中更新数据
|
|
261
139
|
|
|
262
|
-
|
|
263
|
-
> 原因:`userExpired.value` 为 `true` 后,虽然再次调用了 `queryUser`,但在 `user.value` 再次更新前,`user.value` 当前的值仍是“过期的”珊瑚橘
|
|
140
|
+
`{name}` 数据通常在异步函数调用执行结束时更新,但也可以在异步函数执行过程中更新。
|
|
264
141
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
### 异步数据的中途获取与更新
|
|
268
|
-
|
|
269
|
-
> 异步数据中途获取与更新是 `useAsyncData` 独有功能
|
|
270
|
-
|
|
271
|
-
在某些场景下,我们希望异步数据可以在异步获取过程中更新,无需等到获取过程完全结束。
|
|
272
|
-
|
|
273
|
-
可以通过 `options.enhanceFirstArgument = true` 支持这种需求。
|
|
142
|
+
通过配置 `options.enhanceFirstArgument = true` 实现。
|
|
274
143
|
|
|
275
144
|
```js
|
|
276
145
|
import { unFirstArgumentEnhanced, useAsyncData } from 'vue-asyncx'
|
|
@@ -283,10 +152,13 @@ const {
|
|
|
283
152
|
} = useAsyncData('progress', async (init?: number) => {
|
|
284
153
|
const { getData, updateData } = unFirstArgumentEnhanced(init)
|
|
285
154
|
init = unFirstArgumentEnhanced(init).firstArgument
|
|
155
|
+
// 同步更新为入参 10
|
|
286
156
|
updateData(init || 0)
|
|
287
157
|
await wait(100)
|
|
158
|
+
// 间隔 100ms 后,更新为 50
|
|
288
159
|
updateData(50)
|
|
289
160
|
await wait(100)
|
|
161
|
+
// 间隔 100ms 后,返回 100,本次异步函数完全结束。
|
|
290
162
|
return 100
|
|
291
163
|
}, {
|
|
292
164
|
enhanceFirstArgument: true
|
|
@@ -295,85 +167,58 @@ const {
|
|
|
295
167
|
queryProgress(10)
|
|
296
168
|
```
|
|
297
169
|
|
|
298
|
-
在上述代码的最后一行调用 `queryProgress(10)` 后:
|
|
299
|
-
- `progress.value` 会立即更新为 `10`
|
|
300
|
-
- 100ms 后 `progress.value` 更新为 `50`
|
|
301
|
-
- 再过 100ms 后,`progress.value` 更新为 `100`,本次调用结束
|
|
302
|
-
|
|
303
|
-
注意到在传入 `useAsyncData` 的 `fn` 内,有
|
|
304
|
-
|
|
305
|
-
```js
|
|
306
|
-
const { getData, updateData } = unFirstArgumentEnhanced(init)
|
|
307
|
-
init = unFirstArgumentEnhanced(init).firstArgument
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
原理:
|
|
311
|
-
|
|
312
170
|
当 `options.enhanceFirstArgument = true` 后
|
|
313
|
-
- `
|
|
314
|
-
-
|
|
171
|
+
- 异步函数的首个参数 `init` 便被转换为 `FirstArgumentEnhanced` 类型,包含 `{ getData, updateData, firstArgument }` 属性。
|
|
172
|
+
- 调用 `queryProgress(10)` 时传入的 `10` 在异步函数内部被赋在 `init.firstArgument` 上
|
|
315
173
|
- `unFirstArgumentEnhanced(init)` 先解构出 `getData` 和 `updateData`,再将 `init` 重新赋值为传入的 `10`
|
|
316
174
|
|
|
317
|
-
>
|
|
318
|
-
> `const { getData, updateData, firstArgument } = init`
|
|
319
|
-
> 但是这样写需要自行处理 TS 类型问题,因此提供了 `unFirstArgumentEnhanced` 辅助函数。
|
|
175
|
+
> 注意,异步函数的 `init` 不可以直接设置默认值。如:`(init: number = 0) => {}`,可以通过 `unFirstArgumentEnhanced(init, 0)` 设置默认值。
|
|
320
176
|
|
|
321
|
-
|
|
177
|
+
> 注意,`queryProgress()` 时,`'firstArgument' in unFirstArgumentEnhanced(init)` === `false`,这可以用来区分 `queryProgress()` 与 `queryProgress(undefined)`
|
|
322
178
|
|
|
323
|
-
|
|
324
|
-
- 在 `fn` 内部实现的最上方,加上上述的两行代码,余下即可正常使用
|
|
179
|
+
### Debounce
|
|
325
180
|
|
|
326
|
-
|
|
181
|
+
```ts
|
|
182
|
+
import { debounce } from 'es-toolkit';
|
|
327
183
|
|
|
328
|
-
```js
|
|
329
184
|
const {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
} = useAsyncData('
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
await wait(100)
|
|
338
|
-
return 100
|
|
339
|
-
}, {
|
|
340
|
-
enhanceFirstArgument: true
|
|
185
|
+
user,
|
|
186
|
+
queryUser
|
|
187
|
+
} = useAsyncData('user', getUserApi, {
|
|
188
|
+
immediate: true,
|
|
189
|
+
setup(fn) {
|
|
190
|
+
return debounce(fn, 500)
|
|
191
|
+
}
|
|
341
192
|
})
|
|
342
|
-
|
|
343
|
-
queryProgress()
|
|
344
193
|
```
|
|
345
194
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
```js
|
|
349
|
-
const firstArgumentEnhanced = unFirstArgumentEnhanced(arguments[0])
|
|
350
|
-
const undefinedOrEmpty = 'firstArgument' in firstArgumentEnhanced
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
即
|
|
354
|
-
|
|
355
|
-
- `firstArgumentEnhanced` 存在 `firstArgument` 属性时,是 `queryProgress(undefined)`
|
|
356
|
-
- `firstArgumentEnhanced` 不存在 `firstArgument` 属性时,是 `queryProgress()`
|
|
357
|
-
|
|
358
|
-
本块 api 设计思考过程见
|
|
359
|
-
|
|
360
|
-
- [rfc1-async-data-update](./docs/rfc1-async-data-update.md)
|
|
195
|
+
上面例子中,`queryUser` 等价于 `debounce(fn, 500)`。可以使用任意你喜欢的 `debounce` 函数
|
|
361
196
|
|
|
362
|
-
|
|
197
|
+
> `fn` 是 `useAsyncData` 内部对 `getUserApi` 做的封装。`setup` 返回值为函数类型时,会成为最终返回的 `queryUser`,否则,`queryUser` === `fn`
|
|
363
198
|
|
|
364
|
-
|
|
365
|
-
- `setData` 不保证设置成功(比如发生了乱序响应的情况)
|
|
366
|
-
- 接上,`setData` 支持处理乱序响应,一旦有新的调用触发 `setData`,旧调用的 `setData` 操作会被忽略
|
|
199
|
+
## API
|
|
367
200
|
|
|
368
|
-
|
|
201
|
+
### 响应
|
|
369
202
|
|
|
370
|
-
|
|
203
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
204
|
+
| ------------------------ | ------------------------------- | ---------------- | --------- |
|
|
205
|
+
| {name} | 异步函数的返回数据 | any \\ undefined | undefined |
|
|
206
|
+
| query{Name}Loading | 异步函数执行时的加载状态 | boolean | false |
|
|
207
|
+
| query{Name}Arguments | 异步函数执行时的传入的参数列表 | any[] \\ [] | [] |
|
|
208
|
+
| query{Name}ArgumentFirst | query{Name}Arguments 的首个参数 | any \\ undefined | undefined |
|
|
209
|
+
| query{Name}Error | 异步函数执行时的异常 | any \\ undefined | undefined |
|
|
210
|
+
| {name}Expired | {name} 数据是否过期 | any \\ undefined | undefined |
|
|
371
211
|
|
|
372
|
-
|
|
373
|
-
- 对于在 `data` 值初始化后需要干的其它事情,可以在 `useAsyncData` **外部** 通过 vue 的 watch data 去触发
|
|
374
|
-
- 对于 `useAsyncData` 整体而言,我们将与 `data` 值相关的代码都聚集在了一起
|
|
375
|
-
- loading、error、expired、arguments 等数据与 data 或 fn 紧密相关
|
|
376
|
-
- watch 设置了 fn 的调用时机,即初始化 data 的时机
|
|
212
|
+
### 配置
|
|
377
213
|
|
|
378
|
-
|
|
214
|
+
| 配置名 | 描述 | 类型 | 默认值 |
|
|
215
|
+
| --------------------------- | ----------------------------------------------------- | ------------------------------------------------------- | --------- |
|
|
216
|
+
| immediate | 是否立即执行 | boolean | false |
|
|
217
|
+
| watch | 传入 vue watch 的侦听数据源,发生变动时执行 `handler` | 与 vue WatchSource 一致 | - |
|
|
218
|
+
| watchOptions | 传入 vue watch 的配置项 | 支持全部 vue WatchOptions,另有 `handlerCreator` 配置项 | - |
|
|
219
|
+
| watchOptions.handlerCreator | 自定义传入 `watch` 的 `handler` | `(fn: Fn) => WatchCallback` | - |
|
|
220
|
+
| initialData | data 的初始值 | any | undefined |
|
|
221
|
+
| shallow | 是否使用 `shallowRef` 保存 data,默认使用 `ref` | boolean | false |
|
|
222
|
+
| enhanceFirstArgument | 是否强化首个入参 | boolean | false |
|
|
223
|
+
| setup | 转换函数或执行其它初始化操作 | `(fn: Fn) => ((...args: any) => any) \| void` | - |
|
|
379
224
|
|
package/dist/vue-asyncx.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ declare type UseAsyncOptions<Fn extends (...args: any) => any> = {
|
|
|
50
50
|
watch?: WatchSource;
|
|
51
51
|
watchOptions?: UseAsyncWatchOptions<Fn>;
|
|
52
52
|
immediate?: boolean;
|
|
53
|
+
setup?: (fn: Fn) => ((...args: any) => any) | void;
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
declare type UseAsyncResult<Fn extends (...args: any) => any, Name extends string> = {
|
package/dist/vue-asyncx.js
CHANGED
|
@@ -1,150 +1,191 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
1
|
+
var G = Object.defineProperty, L = Object.defineProperties;
|
|
2
|
+
var P = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var F = Object.getOwnPropertySymbols;
|
|
4
|
+
var O = Object.prototype.hasOwnProperty, b = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var H = (e, t, r) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, T = (e, t) => {
|
|
6
|
+
for (var r in t || (t = {}))
|
|
7
|
+
O.call(t, r) && H(e, r, t[r]);
|
|
8
|
+
if (F)
|
|
9
|
+
for (var r of F(t))
|
|
10
|
+
b.call(t, r) && H(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
for (var
|
|
16
|
-
|
|
17
|
-
if (e != null &&
|
|
18
|
-
for (var
|
|
19
|
-
|
|
20
|
-
return
|
|
12
|
+
}, x = (e, t) => L(e, P(t));
|
|
13
|
+
var $ = (e, t) => {
|
|
14
|
+
var r = {};
|
|
15
|
+
for (var n in e)
|
|
16
|
+
O.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
17
|
+
if (e != null && F)
|
|
18
|
+
for (var n of F(e))
|
|
19
|
+
t.indexOf(n) < 0 && b.call(e, n) && (r[n] = e[n]);
|
|
20
|
+
return r;
|
|
21
21
|
};
|
|
22
|
-
import { ref as
|
|
23
|
-
function
|
|
24
|
-
|
|
22
|
+
import { ref as E, computed as l, watch as U, shallowRef as C } from "vue";
|
|
23
|
+
function q(e) {
|
|
24
|
+
if (!e) return "";
|
|
25
|
+
const t = e[0], r = e.slice(1);
|
|
26
|
+
return t.toUpperCase() + r;
|
|
27
|
+
}
|
|
28
|
+
function N() {
|
|
29
|
+
const e = E({
|
|
30
|
+
// 发起的调用
|
|
31
|
+
track: 0,
|
|
32
|
+
// 更新的调用
|
|
33
|
+
progress: 0,
|
|
34
|
+
// 完成的调用,包含报错情况
|
|
35
|
+
finished: 0,
|
|
36
|
+
// 完成(正常)的调用,不含报错情况
|
|
37
|
+
ok: 0
|
|
38
|
+
});
|
|
39
|
+
function t() {
|
|
40
|
+
const r = e.value, n = ++r.track;
|
|
41
|
+
return {
|
|
42
|
+
progress() {
|
|
43
|
+
r.progress >= n || (r.progress = n);
|
|
44
|
+
},
|
|
45
|
+
finish(u = !1) {
|
|
46
|
+
r.finished >= n || (r.finished = n, u || (r.ok = n));
|
|
47
|
+
},
|
|
48
|
+
expired(u) {
|
|
49
|
+
return u ? u === "progress" ? r.progress > n || r.finished >= n : u === "result:ok" ? r.progress > n || r.ok > n : r.progress > n || r.finished > n : r.track > n;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return t.tracking = l(() => e.value.track > 0), t.latest = {
|
|
54
|
+
// 已完成
|
|
55
|
+
finished: l(() => e.value.track === e.value.finished),
|
|
56
|
+
// 已成功
|
|
57
|
+
ok: l(() => e.value.track === e.value.ok)
|
|
58
|
+
}, t.has = {
|
|
59
|
+
// 存在完成
|
|
60
|
+
finished: l(() => e.value.finished > 0),
|
|
61
|
+
// 存在成功
|
|
62
|
+
ok: l(() => e.value.ok > 0),
|
|
63
|
+
// 存在更新
|
|
64
|
+
progress: l(() => e.value.progress > 0)
|
|
65
|
+
}, t;
|
|
66
|
+
}
|
|
67
|
+
function z(e, t) {
|
|
68
|
+
if (typeof t != "function") return e;
|
|
69
|
+
try {
|
|
70
|
+
const r = t(e);
|
|
71
|
+
return typeof r == "function" ? r : e;
|
|
72
|
+
} catch (r) {
|
|
73
|
+
return e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function I(...e) {
|
|
77
|
+
var h;
|
|
25
78
|
if (!Array.isArray(e) || !e.length) throw TypeError("参数错误:未传递");
|
|
26
|
-
const { name:
|
|
27
|
-
if (typeof
|
|
28
|
-
if (typeof
|
|
29
|
-
const
|
|
30
|
-
var
|
|
31
|
-
return (
|
|
32
|
-
}),
|
|
33
|
-
function
|
|
34
|
-
const d =
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
79
|
+
const { name: t, fn: r, options: n } = typeof e[0] == "function" ? { name: "method", fn: e[0], options: e[1] } : { name: e[0] || "method", fn: e[1], options: e[2] };
|
|
80
|
+
if (typeof t != "string") throw TypeError("参数错误:name");
|
|
81
|
+
if (typeof r != "function") throw TypeError("参数错误:fn");
|
|
82
|
+
const u = E(!1), p = E(), _ = l(() => {
|
|
83
|
+
var a;
|
|
84
|
+
return (a = p.value) == null ? void 0 : a[0];
|
|
85
|
+
}), k = E(), y = N();
|
|
86
|
+
function v(...a) {
|
|
87
|
+
const d = y(), A = (c) => {
|
|
88
|
+
k.value = void 0, u.value = !0, p.value = c;
|
|
89
|
+
}, f = (c, { scene: s }) => {
|
|
90
|
+
d.finish(s === "error"), !d.expired() && (s === "error" && (k.value = c), u.value = !1, p.value = void 0);
|
|
38
91
|
};
|
|
39
|
-
A(
|
|
92
|
+
A(a);
|
|
40
93
|
try {
|
|
41
|
-
const c =
|
|
94
|
+
const c = r(...a);
|
|
42
95
|
return c instanceof Promise ? c.then(
|
|
43
|
-
() =>
|
|
44
|
-
(
|
|
45
|
-
) :
|
|
96
|
+
() => f(void 0, { scene: "normal" }),
|
|
97
|
+
(s) => f(s, { scene: "error" })
|
|
98
|
+
) : f(void 0, { scene: "normal" }), c;
|
|
46
99
|
} catch (c) {
|
|
47
|
-
throw
|
|
100
|
+
throw f(c, { scene: "error" }), c;
|
|
48
101
|
}
|
|
49
102
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
103
|
+
const m = z(v, n == null ? void 0 : n.setup);
|
|
104
|
+
if (n) {
|
|
105
|
+
const a = () => {
|
|
106
|
+
}, w = Object.assign(
|
|
53
107
|
{},
|
|
54
|
-
"immediate" in
|
|
55
|
-
(
|
|
56
|
-
), { handlerCreator: d } =
|
|
57
|
-
const
|
|
58
|
-
if (typeof d != "function") return
|
|
108
|
+
"immediate" in n ? { immediate: n.immediate } : {},
|
|
109
|
+
(h = n.watchOptions) != null ? h : {}
|
|
110
|
+
), { handlerCreator: d } = w, A = $(w, ["handlerCreator"]), { watch: f } = n, s = (() => {
|
|
111
|
+
const i = () => m();
|
|
112
|
+
if (typeof d != "function") return i;
|
|
59
113
|
try {
|
|
60
|
-
const
|
|
61
|
-
return typeof
|
|
62
|
-
} catch (
|
|
63
|
-
return
|
|
114
|
+
const o = d(m);
|
|
115
|
+
return typeof o == "function" ? o : i;
|
|
116
|
+
} catch (o) {
|
|
117
|
+
return i;
|
|
64
118
|
}
|
|
65
119
|
})();
|
|
66
|
-
|
|
120
|
+
U(f != null ? f : a, s, A);
|
|
67
121
|
}
|
|
68
122
|
return {
|
|
69
|
-
[
|
|
70
|
-
[`${
|
|
71
|
-
[`${
|
|
72
|
-
[`${
|
|
73
|
-
[`${
|
|
123
|
+
[t]: m,
|
|
124
|
+
[`${t}Loading`]: u,
|
|
125
|
+
[`${t}Arguments`]: p,
|
|
126
|
+
[`${t}ArgumentFirst`]: _,
|
|
127
|
+
[`${t}Error`]: k
|
|
74
128
|
};
|
|
75
129
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const n = e[0], t = e.slice(1);
|
|
79
|
-
return n.toUpperCase() + t;
|
|
80
|
-
}
|
|
81
|
-
const L = "__va_fae";
|
|
82
|
-
function k(...e) {
|
|
130
|
+
const R = "__va_fae";
|
|
131
|
+
function Q(...e) {
|
|
83
132
|
if (!Array.isArray(e) || !e.length) throw TypeError("参数错误:未传递");
|
|
84
|
-
const { name:
|
|
85
|
-
if (typeof
|
|
86
|
-
if (typeof
|
|
87
|
-
const c =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// 完成序号(即:fn 第 finished 次调用完成)
|
|
91
|
-
finished: 0,
|
|
92
|
-
// 数据被更新的调用序号(即:data 数据由第 dataUpdateByCalled 次调用更新)
|
|
93
|
-
dataUpdateByCalled: 0,
|
|
94
|
-
// 数据完成更新序号(即:data 数据由第 dataUpdateByFinished 次调用完成后更新)
|
|
95
|
-
dataUpdateByFinished: 0
|
|
96
|
-
}), h = _ ? j(l) : F(l), E = H(() => !(s.value.dataUpdateByFinished >= s.value.finished || s.value.dataUpdateByCalled > s.value.finished));
|
|
97
|
-
function y(a, { sn: r, scene: i }) {
|
|
98
|
-
r < s.value.dataUpdateByCalled || (h.value = a, s.value.dataUpdateByCalled = r, i === "finish" && (s.value.dataUpdateByFinished = r));
|
|
133
|
+
const { name: t, fn: r, options: n } = typeof e[0] == "function" ? { name: "data", fn: e[0], options: e[1] } : { name: e[0] || "data", fn: e[1], options: e[2] };
|
|
134
|
+
if (typeof t != "string") throw TypeError("参数错误:name");
|
|
135
|
+
if (typeof r != "function") throw TypeError("参数错误:fn");
|
|
136
|
+
const c = n || {}, { enhanceFirstArgument: u, initialData: p, shallow: _ } = c, k = $(c, ["enhanceFirstArgument", "initialData", "shallow"]), y = _ ? C(p) : E(p), v = C();
|
|
137
|
+
function m(s, { track: i, scene: o }) {
|
|
138
|
+
o === "update" && i.progress(), !(o === "finish" && i.expired("result:ok")) && (o === "update" && i.expired("progress") || (y.value = s, v.value = i));
|
|
99
139
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
140
|
+
function h(s, { scene: i, track: o }) {
|
|
141
|
+
o.finish(i === "error"), i === "normal" && m(s, { track: o, scene: "finish" });
|
|
102
142
|
}
|
|
103
|
-
function
|
|
104
|
-
enhanceFirstArgument:
|
|
105
|
-
|
|
143
|
+
function w(s, {
|
|
144
|
+
enhanceFirstArgument: i,
|
|
145
|
+
track: o
|
|
106
146
|
}) {
|
|
107
|
-
if (!
|
|
108
|
-
const [
|
|
109
|
-
return [
|
|
110
|
-
[
|
|
111
|
-
},
|
|
112
|
-
getData: () =>
|
|
113
|
-
updateData: (
|
|
114
|
-
}), ...
|
|
147
|
+
if (!i) return s;
|
|
148
|
+
const [g, ...j] = s;
|
|
149
|
+
return [x(T({
|
|
150
|
+
[R]: !0
|
|
151
|
+
}, s.length ? { firstArgument: g } : {}), {
|
|
152
|
+
getData: () => y.value,
|
|
153
|
+
updateData: (D) => (m(D, { track: o, scene: "update" }), D)
|
|
154
|
+
}), ...j];
|
|
115
155
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
156
|
+
const a = N();
|
|
157
|
+
function d(...s) {
|
|
158
|
+
const i = a();
|
|
159
|
+
s = w(s, { enhanceFirstArgument: u, track: i });
|
|
119
160
|
try {
|
|
120
|
-
const
|
|
121
|
-
return
|
|
161
|
+
const o = r(...s);
|
|
162
|
+
return o instanceof Promise ? o.then(
|
|
122
163
|
// promise 正常结束
|
|
123
|
-
(
|
|
164
|
+
(g) => h(g, { scene: "normal", track: i }),
|
|
124
165
|
// promise 出现拒绝
|
|
125
|
-
(
|
|
126
|
-
) :
|
|
127
|
-
} catch (
|
|
128
|
-
throw
|
|
166
|
+
(g) => h(g, { scene: "error", track: i })
|
|
167
|
+
) : h(o, { scene: "normal", track: i }), o;
|
|
168
|
+
} catch (o) {
|
|
169
|
+
throw h(o, { scene: "error", track: i }), o;
|
|
129
170
|
}
|
|
130
171
|
}
|
|
131
|
-
const
|
|
132
|
-
return
|
|
133
|
-
[
|
|
134
|
-
[`${
|
|
172
|
+
const A = I(`query${q(t)}`, d, k), f = l(() => a.tracking.value ? v.value ? v.value.expired("result") : a.has.finished.value : !1);
|
|
173
|
+
return x(T({}, A), {
|
|
174
|
+
[t]: y,
|
|
175
|
+
[`${t}Expired`]: f
|
|
135
176
|
});
|
|
136
177
|
}
|
|
137
|
-
function
|
|
138
|
-
if (!
|
|
139
|
-
const
|
|
140
|
-
return arguments.length === 2 &&
|
|
178
|
+
function S(e, t) {
|
|
179
|
+
if (!M(e)) throw Error("请配置 options.enhanceFirstArgument = true");
|
|
180
|
+
const r = e;
|
|
181
|
+
return arguments.length === 2 && r.firstArgument === void 0 ? x(T({}, r), { firstArgument: t }) : r;
|
|
141
182
|
}
|
|
142
|
-
function
|
|
143
|
-
return typeof e == "object" && !!e &&
|
|
183
|
+
function M(e) {
|
|
184
|
+
return typeof e == "object" && !!e && R in e;
|
|
144
185
|
}
|
|
145
186
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
187
|
+
S as unFirstArgumentEnhanced,
|
|
188
|
+
I as useAsync,
|
|
189
|
+
Q as useAsyncData,
|
|
190
|
+
I as useAsyncFunction
|
|
150
191
|
};
|
package/dist/vue-asyncx.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r.VueAsyncx={},r.Vue))})(this,function(r,t){"use strict";var S=Object.defineProperty,U=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var R=(r,t,f)=>t in r?S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[t]=f,_=(r,t)=>{for(var f in t||(t={}))C.call(t,f)&&R(r,f,t[f]);if(x)for(var f of x(t))N.call(t,f)&&R(r,f,t[f]);return r},D=(r,t)=>U(r,V(t));var O=(r,t)=>{var f={};for(var d in r)C.call(r,d)&&t.indexOf(d)<0&&(f[d]=r[d]);if(r!=null&&x)for(var d of x(r))t.indexOf(d)<0&&N.call(r,d)&&(f[d]=r[d]);return f};function f(e){if(!e)return"";const o=e[0],n=e.slice(1);return o.toUpperCase()+n}function d(){const e=t.ref({track:0,progress:0,finished:0,ok:0});function o(){const n=e.value,i=++n.track;return{progress(){n.progress>=i||(n.progress=i)},finish(p=!1){n.finished>=i||(n.finished=i,p||(n.ok=i))},expired(p){return p?p==="progress"?n.progress>i||n.finished>=i:p==="result:ok"?n.progress>i||n.ok>i:n.progress>i||n.finished>i:n.track>i}}}return o.tracking=t.computed(()=>e.value.track>0),o.latest={finished:t.computed(()=>e.value.track===e.value.finished),ok:t.computed(()=>e.value.track===e.value.ok)},o.has={finished:t.computed(()=>e.value.finished>0),ok:t.computed(()=>e.value.ok>0),progress:t.computed(()=>e.value.progress>0)},o}function P(e,o){if(typeof o!="function")return e;try{const n=o(e);return typeof n=="function"?n:e}catch(n){return e}}function $(...e){var y;if(!Array.isArray(e)||!e.length)throw TypeError("参数错误:未传递");const{name:o,fn:n,options:i}=typeof e[0]=="function"?{name:"method",fn:e[0],options:e[1]}:{name:e[0]||"method",fn:e[1],options:e[2]};if(typeof o!="string")throw TypeError("参数错误:name");if(typeof n!="function")throw TypeError("参数错误:fn");const p=t.ref(!1),m=t.ref(),b=t.computed(()=>{var l;return(l=m.value)==null?void 0:l[0]}),g=t.ref(),E=d();function w(...l){const k=E(),v=a=>{g.value=void 0,p.value=!0,m.value=a},h=(a,{scene:u})=>{k.finish(u==="error"),!k.expired()&&(u==="error"&&(g.value=a),p.value=!1,m.value=void 0)};v(l);try{const a=n(...l);return a instanceof Promise?a.then(()=>h(void 0,{scene:"normal"}),u=>h(u,{scene:"error"})):h(void 0,{scene:"normal"}),a}catch(a){throw h(a,{scene:"error"}),a}}const A=P(w,i==null?void 0:i.setup);if(i){const l=()=>{},T=Object.assign({},"immediate"in i?{immediate:i.immediate}:{},(y=i.watchOptions)!=null?y:{}),{handlerCreator:k}=T,v=O(T,["handlerCreator"]),{watch:h}=i,u=(()=>{const c=()=>A();if(typeof k!="function")return c;try{const s=k(A);return typeof s=="function"?s:c}catch(s){return c}})();t.watch(h!=null?h:l,u,v)}return{[o]:A,[`${o}Loading`]:p,[`${o}Arguments`]:m,[`${o}ArgumentFirst`]:b,[`${o}Error`]:g}}const j="__va_fae";function q(...e){if(!Array.isArray(e)||!e.length)throw TypeError("参数错误:未传递");const{name:o,fn:n,options:i}=typeof e[0]=="function"?{name:"data",fn:e[0],options:e[1]}:{name:e[0]||"data",fn:e[1],options:e[2]};if(typeof o!="string")throw TypeError("参数错误:name");if(typeof n!="function")throw TypeError("参数错误:fn");const a=i||{},{enhanceFirstArgument:p,initialData:m,shallow:b}=a,g=O(a,["enhanceFirstArgument","initialData","shallow"]),E=b?t.shallowRef(m):t.ref(m),w=t.shallowRef();function A(u,{track:c,scene:s}){s==="update"&&c.progress(),!(s==="finish"&&c.expired("result:ok"))&&(s==="update"&&c.expired("progress")||(E.value=u,w.value=c))}function y(u,{scene:c,track:s}){s.finish(c==="error"),c==="normal"&&A(u,{track:s,scene:"finish"})}function T(u,{enhanceFirstArgument:c,track:s}){if(!c)return u;const[F,...M]=u;return[D(_({[j]:!0},u.length?{firstArgument:F}:{}),{getData:()=>E.value,updateData:H=>(A(H,{track:s,scene:"update"}),H)}),...M]}const l=d();function k(...u){const c=l();u=T(u,{enhanceFirstArgument:p,track:c});try{const s=n(...u);return s instanceof Promise?s.then(F=>y(F,{scene:"normal",track:c}),F=>y(F,{scene:"error",track:c})):y(s,{scene:"normal",track:c}),s}catch(s){throw y(s,{scene:"error",track:c}),s}}const v=$(`query${f(o)}`,k,g),h=t.computed(()=>l.tracking.value?w.value?w.value.expired("result"):l.has.finished.value:!1);return D(_({},v),{[o]:E,[`${o}Expired`]:h})}function G(e,o){if(!L(e))throw Error("请配置 options.enhanceFirstArgument = true");const n=e;return arguments.length===2&&n.firstArgument===void 0?D(_({},n),{firstArgument:o}):n}function L(e){return typeof e=="object"&&!!e&&j in e}r.unFirstArgumentEnhanced=G,r.useAsync=$,r.useAsyncData=q,r.useAsyncFunction=$,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-asyncx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/vue-asyncx.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"utils",
|
|
21
21
|
"async",
|
|
22
22
|
"vueuse",
|
|
23
|
-
"hooks"
|
|
23
|
+
"hooks",
|
|
24
|
+
"ahooks"
|
|
24
25
|
],
|
|
25
26
|
"author": "Xu Yiming",
|
|
26
27
|
"license": "MIT",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/node": "^20.14.11",
|
|
33
34
|
"@vitest/coverage-v8": "^2.0.4",
|
|
35
|
+
"es-toolkit": "^1.42.0",
|
|
34
36
|
"jsdom": "^24.1.1",
|
|
35
37
|
"typescript": "^5.5.4",
|
|
36
38
|
"vite": "^5.3.4",
|