DEV Community 👩‍💻👨‍💻

Discussion on: Name a DESIGN PATTERN and WHY u use it 😀 ?????

sargalias profile image
Spyros Argalias

I... Love the observer pattern.

I just find it so satisfying and elegant...

I don't use it with React because it's not needed, but with vanilla JavaScript when something needs an active "watcher" relationship to something else. Or in C# with events and delegates (which are basically the observer pattern).

Sidenote: I find it different to the pubsub pattern. For me pubsub is more like "I'll broadcast something and I don't care who is listening or why". Whereas observer seems like a more cohesive relationship to me. "This event is important, someone is exclusively interested. I'll notify them directly."

sharadcodes profile image
Sharad Raj (He/Him) Author