vue-psa-architecture/src/shared/lib/composables/loader.ts

15 lines
284 B
TypeScript

import { ref } from "vue";
export function useLoader() {
const loading = ref(false);
async function wait<T>(process: Promise<T>): Promise<T> {
loading.value = true;
const res = await process;
loading.value = false;
return res;
}
return { loading, wait };
}