Request: EventRegistery, a CommandRegistery equivalent for native events


Continuing the discussion from Is it appropriate to use the CommandRegistry for native DOM events like mousedown?:

Ok that makes sense, I see how we can’t reuse CommandRegistry in this case. But it does still seem to me that an EventsRegistry would be really useful, especially in a plugin oriented project such as Atom.

Right now I’m running into a problem implementing Drag and Drop in my view. The problem is that is listening for drag and drop. I’m using my own Event delegate class internally, so my handlers are also listening on document… and is getting priority since it registers first.

I can solve the problem by adding listeners on my element instance, but that makes everything much more complicated. Since now I need to mange registrations per instance.

It seems to me that everything would be much cleaner if Atom provided and used internally a delegate pattern EventRegistry just as it’s now using the CommandRegistery.

Can you describe a bit more about: “involved pretty severe intervention in the browser’s native event cascade mechanism”. Wouldn’t this just be another implementation (opt in) of the event delegate pattern as used in other frameworks?

It seems to me that it would have a very similar implementing to the existing CommandRegistry.



If you’d like to check out the pull request I had started, you can view it at

Basically, if we do an event registry I want it to be backward-compatible with listeners registered via Node::addEventListener. This means we need to implement event dispatch ourselves in JavaScript, which is complicated. It’s something we could maybe do in the future but there are many other tasks that are higher priority at the moment. If you’d like to roll your own event manager that works on a single-element basis, that could be a good path toward getting this kind of behavior. Not something we’re ready to commit to globally however.