whirlr

    0.0.4 • Public • Published

    Whirlr

    Build Status

    Control sequencial deferred events for with lock and resume.

    Goal

    • Wait user input and resume.
    • Pool action events after current one
    • Handle them with jQuery.Deferred API

    Requirements

    • jQuery or simply-deferred

    Install

    $ npm install whirlr
    
    $ bower install whirlr
    

    How to use

    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
    

    Run test

    # if you don't install mocha
    $ npm install -g mocha
    # run tests
    $ mocha --compilers coffee:coffee-script --reporter spec
    

    Thanks to:

    • Guys at Quipper

    Keywords

    none

    Install

    npm i whirlr

    DownloadsWeekly Downloads

    0

    Version

    0.0.4

    License

    BSD-2-Clause

    Last publish

    Collaborators

    • mizchi