@@ -355,58 +355,6 @@ Axle provides the usage of Vue Composition API style, which encapsulates the `lo
355
355
</template >
356
356
```
357
357
358
- ### Parallel Utils
359
-
360
- Axle provides some parallel request processing tools, please refer to the following examples.
361
-
362
- ``` html
363
- <script setup >
364
- import { createAxle } from ' @varlet/axle'
365
- import { createUseAxle , useAverageProgress , useHasLoading , useValues } from ' @varlet/axle/use'
366
-
367
- const axle = createAxle (/** @see https://axios-http.com **/ )
368
-
369
- const useAxle = createUseAxle ({ axle })
370
-
371
- const [users , getUsers , { loading: isUsersLoading , downloadProgress: usersDownloadProgress }] = useAxle ({
372
- method: ' get' ,
373
- url: ' /user' ,
374
- })
375
-
376
- const [roles , getRoles , { loading: isRolesLoading , downloadProgress: rolesDownloadProgress }] = useAxle ({
377
- method: ' get' ,
378
- url: ' /role' ,
379
- })
380
-
381
- // At the end of all requests, loading is false
382
- const loading = useHasLoading (isUsersLoading, isRolesLoading)
383
- // At the end of all requests, downloadProgress is 1
384
- const downloadProgress = useAverageProgress (usersDownloadProgress, rolesDownloadProgress)
385
- // Ref<[
386
- // [{ name: 'foo' }, { name: 'bar' }],
387
- // [{ role: 'admin' }, { role: 'user' }]
388
- // ]> <-
389
- // [
390
- // Ref<[{ name: 'foo' }, { name: 'bar' }]>,
391
- // Ref<[{ role: 'admin' }, { role: 'user' }]>
392
- // ]
393
- const usersRoles = useValues (users, roles)
394
-
395
- function sendAllRequest () {
396
- // parallel
397
- getUsers ()
398
- getRoles ()
399
- }
400
- </script >
401
-
402
- <template >
403
- <span >{{ usersRoles }}</span >
404
- <span >{{ loading }}</span >
405
- <span >{{ downloadProgress }}</span >
406
- <button @click =" sendAllRequest" >Send All Request</button >
407
- </template >
408
- ```
409
-
410
358
### API Definition Enhancement
411
359
412
360
` createApi ` is supported since ` v0.9.0 ` , which is used to define APIs.
@@ -503,15 +451,15 @@ before:
503
451
504
452
``` html
505
453
<script setup >
506
- const [users , getUsers , { loading: isUsersLoading }] = useAxle ({
507
- method: ' get' ,
508
- url: ' /user' ,
509
- })
510
-
511
- const [posts , getPosts , { loading: isPostsLoading }] = useAxle ({
512
- method: ' get' ,
513
- url: ' /post' ,
514
- })
454
+ const [users , getUsers , { loading: isUsersLoading }] = useAxle ({
455
+ method: ' get' ,
456
+ url: ' /user' ,
457
+ })
458
+
459
+ const [posts , getPosts , { loading: isPostsLoading }] = useAxle ({
460
+ method: ' get' ,
461
+ url: ' /post' ,
462
+ })
515
463
</script >
516
464
517
465
<template >
@@ -526,15 +474,15 @@ after:
526
474
527
475
``` html
528
476
<script setup >
529
- const [users , getUsers ] = useAxle ({
530
- method: ' get' ,
531
- url: ' /user' ,
532
- })
533
-
534
- const [posts , getPosts ] = useAxle ({
535
- method: ' get' ,
536
- url: ' /post' ,
537
- })
477
+ const [users , getUsers ] = useAxle ({
478
+ method: ' get' ,
479
+ url: ' /user' ,
480
+ })
481
+
482
+ const [posts , getPosts ] = useAxle ({
483
+ method: ' get' ,
484
+ url: ' /post' ,
485
+ })
538
486
</script >
539
487
540
488
<template >
@@ -544,3 +492,8 @@ after:
544
492
<button @click =" getPosts" >Send Request</button >
545
493
</template >
546
494
```
495
+
496
+ ### API Generation Tool
497
+
498
+ The ` API ` generation tool can generate all ` API dispatcher ` and ` type declarations ` through ` Schema ` of ` Openapi3/Swagger2 ` .
499
+ We recommend using [ api-farmer] ( https://github.com/varletjs/api-farmer ) , which has first-party support for ` axle ` and is highly customizable.
0 commit comments