Create a gist now

Instantly share code, notes, and snippets.

Async with bal-util

Async with bal-util

# Method One
(new require('bal-util').Group(next))
    .tasks([
        (complete) -> setTimeout(complete,500)
        (complete) -> setTimeout(complete,250)
    ])
    .run('parallel')

# Method Two
var tasks = (new require('bal-util').Group(next))
tasks.push (complete) -> setTimeout(complete,500)
tasks.push (complete) -> setTimeout(complete,250)
tasks.run('parallel')

# Notes
# `complete` takes one argument - `err` - when passed, the flow will quite and `next` will be triggered with the error
# to run the group in serial instead of parallel use `run('serial')` - parallel is default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment