willconant / flow-js

Javascript Library for Multi-step Asynchronous Logic
MIT License
302 stars 15 forks source link

returnIfAnyError #8

Closed printercu closed 7 years ago

printercu commented 11 years ago

One more helper method to use like this

function your_method(data, callback)
{
  flow.exec(
    function(){ .... /*with this.MULTI() */ },
    function(results){
      if (flow.returnIfAnyError(results, callback)) return
      ... // everything's ok here
    }
  )
}

It looks even better with coffee

(data, callback) ->
  flow.exec(
    ->
      do_smth data, @MULTI()
      do_other data, @MULTI()
    (results) ->
      return if flow.returnIfAnyError results, callback
      # ...
  )