Skip to content

Instantly share code, notes, and snippets.

@balupton
Created January 27, 2013 02:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balupton/4645997 to your computer and use it in GitHub Desktop.
Save balupton/4645997 to your computer and use it in GitHub Desktop.
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