If a child function in Node.JS emits an event, would the parent functions of that functions emit the same event? Like how they do in browser DOM? Or would this
need to be passed down to the children to have the events emitted of off?
From the Node Docs, it mentions "bubbling up the event loop," and I was just wondering if this works for custom emitted events as well.
It's not proper to do this, and I'm aware of this, but here's my temporary fix for handling events with multiple files.
I just emit the event and listen on the process
object. Yes, it's sinful. There are several event listeners already there. If you are watching for more than 2 or 3 events of your own on process
, you are asking for a memory leak, but it works.
I will investigate whether another global can be created and worked with. I have a feeling Node's upcoming support for domain
will make this all easier.
Hap is a node module that can provide something like what you're asking. You set parents or children of each emitter and then let the bubbling take place.