1.1.1 • Published 5 years ago

vue-idle-queue v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Vue-Idle-Queue

Build Status

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'
    }
])