deferred-runner

    0.0.2 • Public • Published

    DeferredRunner

    Manage deferred event queues with lock and unlock control

    Requirements

    • jQuery or simply-deferred

    Install

    $ npm install deferred-runner
    
    $ bower install deferred-runner
    

    How to use

    drunner = new DeferredRunner
    
    # Add 1st queue
    drunner.addQueue (d) ->
      console.log 'queue 1'
      setTimeout ->
        d.resolve()
      , 100
    
    # Add 2nd queue
    drunner.addQueue (d) ->
      console.log 'queue 2'
    
      # add queue to last
      drunner.addQueue (d) ->
        console.log 'queue 3'
        d.resolve()
      d.resolve()
    
    # stop runner execution
    drunner.lock()
    setTimeout ->
      console.log 'start'
      drunner.unlock()
    , 100
    

    Result

    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
    

    Keywords

    none

    Install

    npm i deferred-runner

    DownloadsWeekly Downloads

    0

    Version

    0.0.2

    License

    BSD-2-Clause

    Last publish

    Collaborators

    • mizchi