f / f/vue-wait
add delay option
- Dominant language
- JavaScript
- Stars
- 2k
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes the response is too fast (e.g. cache) so delay is good solution to avoid loading spinner if that's shows only for few milliseconds.
Here is my util fot that:
```javascript
import { createActionHelpers } from 'vuex-loading'
import { delay } from 'lodash/function'
export function createDelayedLoading (options, wait = 1) {
let actionHelpers = createActionHelpers(options)
let { startLoading: startLoadingFn, endLoading: endLoadingFn } = actionHelpers
if (wait) {
let delayed = null
actionHelpers = {
startLoading: (dispatcher, loader, callback) => {
delayed = delay(() => {
startLoadingFn(dispatcher, loader, callback)
}, wait)
},
endLoading: (dispatcher, loader) => {
clearTimeout(delayed)
endLoadingFn(dispatcher, loader)
}
}
}
return actionHelpers
}
```
What do you think about adding something similar to the project?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.