@data-fair/lib-vue 1.13.3 → 1.13.5

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/async-action.d.ts CHANGED
@@ -5,10 +5,10 @@ type AsyncActionOptions = {
5
5
  success?: PartialUiNotif;
6
6
  catch?: 'error' | 'success' | 'all';
7
7
  };
8
- export declare function asyncAction<F extends (...args: any[]) => Promise<any>>(fn: F, options?: AsyncActionOptions): {
8
+ export declare function useAsyncAction<F extends (...args: any[]) => Promise<any>>(fn: F, options?: AsyncActionOptions): {
9
9
  execute: F;
10
10
  notif: Ref<UiNotif | undefined>;
11
11
  loading: Ref<boolean>;
12
12
  error: Ref<string | undefined>;
13
13
  };
14
- export {};
14
+ export default useAsyncAction;
package/async-action.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // similar to withUiNotif but more powerful
2
2
  import { ref } from 'vue'
3
3
  import { useUiNotif, getFullNotif, getErrorMsg } from './ui-notif.js'
4
- export function asyncAction (fn, options) {
4
+ export function useAsyncAction (fn, options) {
5
5
  const { sendUiNotif } = useUiNotif()
6
6
  const notif = ref()
7
7
  const loading = ref(false)
@@ -21,9 +21,8 @@ export function asyncAction (fn, options) {
21
21
  }
22
22
  return result
23
23
  } catch (err) {
24
- const errorMsg = getErrorMsg(err)
25
- error.value = errorMsg
26
- const errorNotif = getFullNotif({ msg: options?.error ?? '', error: errorMsg })
24
+ error.value = getErrorMsg(err)
25
+ const errorNotif = getFullNotif({ msg: options?.error ?? '', error: err })
27
26
  notif.value = errorNotif
28
27
  if (options?.catch !== 'error' && options?.catch !== 'all') {
29
28
  sendUiNotif(errorNotif)
@@ -33,3 +32,4 @@ export function asyncAction (fn, options) {
33
32
  }
34
33
  return { execute, notif, loading, error }
35
34
  }
35
+ export default useAsyncAction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.13.3",
3
+ "version": "1.13.5",
4
4
  "description": "Composables and other utilities for Vue applications in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [