mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-01 03:36:40 +00:00
19 lines
456 B
TypeScript
19 lines
456 B
TypeScript
export const useLoadingTrigger = () => {
|
|
const { $state } = useNuxtApp()
|
|
|
|
return {
|
|
withLoading: (handler: (param?: any) => Promise<void> | void) => async (param?: any) => {
|
|
if (param?.shouldShowLoading !== false) {
|
|
$state.isLoading.value = true
|
|
}
|
|
try {
|
|
await handler(param)
|
|
} finally {
|
|
if (param?.shouldShowLoading !== false) {
|
|
$state.isLoading.value = false
|
|
}
|
|
}
|
|
},
|
|
}
|
|
}
|