TheCat
TheCat

Reputation: 737

Is an Observer pattern useful in JS?

I've read some articles about the Observer design pattern in JavaScript, but I don't get it: it seems to me quite useless since JS has events. Am I missing something?

Upvotes: 1

Views: 745

Answers (1)

luanped
luanped

Reputation: 3198

Reacting to events like click, resize etc is one thing but limited to the DOM events. However without going into details here, if you look at a library like RxJS (which uses the Observer pattern) you will be able to build powerful Reactive systems, where essentially anything could be treated like events, which in addition to the standard event system, they can be composed, mapped, etc

Upvotes: 2

Related Questions