An easy chainable API for dependency based asynchronous flow.
flow! .add \one, (cb) -> cb null, 1 .add \two, (cb) -> cb null, 1 .add \added, <[one two]>, (cb) -> cb null, @one + @two .error (e) -> throw e .done (v) -> console.log 'The answer is: ', v.added .run!
By putting it in a Depencency Graph (link needed), when run is called, all functions are executed as soon as possible. When all dependencies for a node have been fulfilled, the graph executes that node (in parrallel). When a node has nothing to point to it is considered an end of the graph and the value is collected for the done callback.
By just declaring dependencies for the callbacks you request scope where needed and the graph figures it out.
- Unit test ALL THE THINGS!
- Generate a GraphViz (link needed) DOT graph with a method on Graph.
- Maybe expose the graph to flow(), to be able to create a DOT graph out of defined flows.