feat: add loading
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
const pendingCount = ref(0)
|
||||
const loading = ref(false)
|
||||
|
||||
export function useLoading() {
|
||||
function start() {
|
||||
pendingCount.value++
|
||||
loading.value = true
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (pendingCount.value > 0) {
|
||||
pendingCount.value--
|
||||
}
|
||||
if (pendingCount.value === 0) {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return { loading, start, stop }
|
||||
}
|
||||
Reference in New Issue
Block a user