Hi,
I am really liking the new domains feature. However I have a question: "How do I leave a domain"
Is my undesrtanding correct?:
function b(callback) {
// I am running inside the domain created in a
fs.readFile('some-file', 'utf-8', function(err, val) {
// I am running inside the domain created in a
if (err) return callback(err);
callback(undefined, val.replace('A','B'));
});
}
function a() {
var d=domain.create();
d.run(b.bind(null, callback))
}
function callback() {
// I am running inside the domain created in a
}
If so, then how do I leave a domain? Simply dispose of it? Then in which domain am I afterwards? Think nested domains. Am I in the one I was in before doing *domain.run()* in *a*?
I I'm wrong in my understanding, then how do I ensure that all my async calls/callbacks remain in the domain I created?
I would really appreciate if someone could explain this, since I am about to embark on some major efforts that would really benefit from using domains. Understanding how they work would be sort of fundamental ;)
Regards,
Philipp