Joe Honton
Mar 15, 2023

--

Event driven programming has not received much attention from front-end developers who seem to be stuck in their thinking that classes vs. functions is their biggest decision in life.

Once I began using CustomEvent and dispatchEvent en force, it untangled lots of up and down object tree traversals. Plus, it allowed me to write and deeply test the action-producing code in isolation, with only a vague idea that some other thing will eventually need to know about that action.

Just to be clear: a good event bus strategy doesn't need to dangle off the window object. I like to use EventTarget as the base of my own custom bus. Very satisfying.

--

--

Joe Honton
Joe Honton

Written by Joe Honton

Princeps geographus, Read Write Tools

Responses (1)