This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/store/helper.js
kolaente f9d295fc67
Some checks failed
continuous-integration/drone/push Build is failing
Only show loading spinner over menu when loading namespaces
2020-12-23 21:26:43 +01:00

19 lines
405 B
JavaScript

import {LOADING} from './mutation-types'
export const setLoading = (context, loadFunc = null) => {
const timeout = setTimeout(() => {
if (loadFunc === null) {
context.commit(LOADING, true, {root: true})
} else {
loadFunc(true)
}
}, 100)
return () => {
clearTimeout(timeout)
if (loadFunc === null) {
context.commit(LOADING, false, {root: true})
} else {
loadFunc(false)
}
}
}