whirlr

deferred event manager

Whirlr

Control sequencial deferred events for with lock and resume.

  • Wait user input and resume.
  • Pool action events after current one
  • Handle them with jQuery.Deferred API
  • jQuery or simply-deferred
$ npm install whirlr
$ bower install whirlr
whirlr = new Whirlr
 
# Add 1st queue
whirlr.add (d) ->
  console.log 'queue 1'
  setTimeout ->
    d.resolve()
  , 100
 
# Add 2nd queue
whirlr.add (d) ->
  console.log 'queue 2'
 
  # add queue to last
  whirlr.add (d) ->
    console.log 'queue 3'
    d.resolve()
  d.resolve()
 
# stop runner execution
whirlr.stop()
setTimeout ->
  console.log 'start'
  whirlr.resume()
, 100
console.log 'loaded'

Result

loaded
start
queue 1
queue 2
queue 3
# if you don't install mocha
$ npm install -g mocha
# run tests
$ mocha --compilers coffee:coffee-script --reporter spec
  • Guys at Quipper