UNPKG

@f3ve/vue-notify-composables

Version:
2 lines (1 loc) 548 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue");function _(l,e){const t=n.ref(!1),c=n.ref(),a=n.ref();async function s(...u){try{i(),d();const r=await l(...u);r?y(r):f(),e!=null&&e.onSuccess&&e.onSuccess(r)}catch(r){f(),v(r),e!=null&&e.onError&&e.onError(r)}finally{o()}}function i(){t.value=!0}function o(){t.value=!1}function v(u){c.value=u}function d(){c.value=void 0}function y(u){c.value=u}function f(){a.value=void 0}return{result:a,error:c,loading:t,exec:s}}exports.useNotifyRequest=_;