vue-idle-queue
v1.1.1
Published
A Vue.js plugin for executing queues of callbacks in browsers' idle time
Downloads
30
Readme
Vue-Idle-Queue
Vue module that runs multiple callbacks in each requestIdleCallback until before it reaches the deadline time. It helps to execute lots of lightweight callbacks faster. This module uses promises interface to return callbacks results.
Usage
main.js:
import Vue from 'vue'
import App from './App.vue'
import VueIdleQueue from 'vue-idle-queue'
Vue.use(VueIdleQueue)Using promise interface:
this.$onIdleQueue([
() => {
console.log('Im the first in queue')
return 'result of the first callback'
},
() => {
console.log('Im the second in queue')
return 'result of the second callback'
}
]).then(results => console.log('Queue results:', results))Using async\await for fetching results:
const [ result1, result2 ] = await this.$onIdleQueue([
() => {
console.log('Im the first in queue')
return 'result of the first callback'
},
() => {
console.log('Im the second in queue')
return 'result of the second callback'
}
])