Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.46 KB

queue.md

File metadata and controls

39 lines (31 loc) · 1.46 KB

Back to home

Queue

Allow you to run sequentially a huge amount of methods with less impact of ressources. The queue CONFIG contains few parameters:

$.queue({ delay: 50, continue: false, thread: 2 })
    .add( FNC )
    .add( [FNC, FNC] )
    .execute( CALLBACK )
Parameters Description Type
delay Delay time in ms between 2 functions.
Default: 25
NUMBER
continue Allow you to stop the queue on error (false).
Default: true
BOOLEAN
thread Allow you to run multiple thread at the same time. (!) Delay and continue parameters are drop when the value is higher then 1.
Default: 1
NUMBER

.add( FNC || ARRAY )

Each FNC will be trigger with the response of the previous FNC. The add method allow you to push a single method or an array of methods collection.

.execute( CALLBACK )

The execute method will run the queue sequentially. The callback method will be trigger when the queue end with some stats information to let you perform some other actions based on

$.queue()
    .add(() => {
        return "My custom error message"
    })
    .add(res => {
        console.log(res) // My custom error message
        return true
    })
    .add([
        res => { ... }, 
        res => { ... }
    ])
    .execute(stats => {
        console.log(stats) // { error: [...], success: 1 }
    })