@tb-dev/vue 2.0.5 → 2.0.6

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.
@@ -1,12 +1,13 @@
1
+ import { Ref, ShallowRef } from 'vue';
1
2
  import { UseAsyncStateOptions } from '@vueuse/core';
2
3
  type Options = Omit<UseAsyncStateOptions<true>, 'shallow'>;
3
4
  export interface AsyncRefOptions extends Options {
4
5
  immediate?: boolean;
5
6
  }
6
7
  export declare function asyncRef<T>(initial: T, fn: () => Promise<T>, options?: AsyncRefOptions): {
7
- state: import('vue').Ref<T, T>;
8
- execute: (delay?: number, ...args: any[]) => Promise<T>;
9
- isLoading: import('vue').Ref<boolean, boolean>;
10
- isReady: import('vue').Ref<boolean, boolean>;
8
+ state: ShallowRef<T>;
9
+ isLoading: Readonly<Ref<boolean>>;
10
+ isReady: Readonly<Ref<boolean>>;
11
+ execute: () => Promise<void>;
11
12
  };
12
13
  export {};
package/dist/index.js CHANGED
@@ -92,7 +92,7 @@ function asyncComputed(initial, callback, options) {
92
92
 
93
93
  function asyncRef(initial, fn, options = {}) {
94
94
  const { immediate = true } = options;
95
- const { execute, state, isLoading, isReady } = useAsyncState(fn, initial, {
95
+ const value = useAsyncState(fn, initial, {
96
96
  immediate,
97
97
  onError: handleError,
98
98
  resetOnExecute: false,
@@ -100,11 +100,14 @@ function asyncRef(initial, fn, options = {}) {
100
100
  throwError: false,
101
101
  ...options
102
102
  });
103
+ const execute = async () => {
104
+ await value.execute();
105
+ };
103
106
  return {
104
- state,
105
- execute,
106
- isLoading,
107
- isReady
107
+ state: value.state,
108
+ isLoading: value.isLoading,
109
+ isReady: value.isReady,
110
+ execute
108
111
  };
109
112
  }
110
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/vue",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Vue utilities",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,12 +26,12 @@
26
26
  "dependencies": {
27
27
  "@tb-dev/utils": "^7.0.2",
28
28
  "@vueuse/core": "^13.3.0",
29
- "vue": "^3.5.15"
29
+ "vue": "^3.5.16"
30
30
  },
31
31
  "devDependencies": {
32
- "@tb-dev/eslint-config": "^7.1.5",
33
- "@types/node": "^22.15.23",
34
- "eslint": "^9.27.0",
32
+ "@tb-dev/eslint-config": "^7.1.6",
33
+ "@types/node": "^22.15.29",
34
+ "eslint": "^9.28.0",
35
35
  "prettier": "^3.5.3",
36
36
  "tslib": "^2.8.1",
37
37
  "typedoc": "^0.28.5",