willconant/flow-js — pull request #12 by yau-ref (2014-11-07 00:26:52+00:00)
Title: Sharing data between flow blocks

There are some cases when it is necessary to pass data between the blocks of the flow.

Like there:
http://stackoverflow.com/questions/4234619/how-to-avoid-long-nesting-of-asynchronous-functions-in-node-js
or there:

function(){
redisClient.smembers("names" this);
},function(err, names){
redisClient.select(0,this);
},function(){
redisClient.mget(/* `names` is needed here */, this);
}

We have two options:
1. Keep it in the shared scope - the most obvious and the worst way, since the value could be sensetive and shouldn't be accessed out of the flow.
2. Assign it to `this.varname` - works well, but looks tricky and can cause unexpected behavior in certain circumstances.

So, I've implemented STASH and REVEAL methods for this case:

this.STASH("names", names)
..
names = this.REVEAL("names")