Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var active = null;
var cntr = 0;
process.addAsyncListener(function() {
return { val: ++cntr };
}, {
before: function(context, domain) {
active = domain.val;
},
after: function(context, domain) {
active = null;
}
});
process.nextTick(function() {
process._rawDebug('val 1:', active);
process.nextTick(function() {
process._rawDebug('val 3:', active);
});
});
process.nextTick(function() {
process._rawDebug('val 2:', active);
process.nextTick(function() {
process._rawDebug('val 4:', active);
});
});
// output:
// val 1: 2
// val 2: 3
// val 3: 4
// val 4: 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.