Closed creationix closed 14 years ago
The special "this" available in each function of the flow will apply the next function in the flow with whatever parameters it is called with, so it should work great with Node's built-in async functions already. Here's an example with some async file IO:
flow.exec(
function() {
fs.rename("/tmp/hello", "/tmp/world", this);
},function(err) {
if (err) throw err;
fs.stat("/tmp/world", this);
},function(err, stats) {
if (err) throw err;
sys.puts("stats: " + JSON.stringify(stats));
}
);
Does that cover your suggestion? Or is there something I'm missing?
Oh, cool. I didn't realize it supported multiple arguments. Brilliant idea by the way.
You could modify this slightly to work with node's async interface where the first parameter to the callback is the error message. Then it would work with all the built-in node async functions out of the box.