DEV Community

Cover image for The Power of the Observer Pattern in JavaScript

The Power of the Observer Pattern in JavaScript

jsmanifest on October 05, 2019

Find me on medium In this post, we will be going over the Observer Pattern and implementing it with JavaScript so that hopefully you can attain a ...
Collapse
 
arekx profile image
Aleksandar Panic

This is good for other languages which do not have event support, why would this be better than using EventTarget api?

developer.mozilla.org/en-US/docs/W...

Collapse
 
thepeoplesbourgeois profile image
Josh • Edited

I agree. This demonstration of the observer pattern suits languages other than JavaScript for broadcasting events, and is a great exercise in building out the pattern for oneself. But given that JS is an event-based runtime, much of the code here essentially reimplements parts of the event loop, but doesn't have the same depth of performance optimizations as the language builtins do