Event-driven architecture decouples components and enables scalable, maintainable code. At Google, we use it extensively in large SPAs.
Why Event-Driven?
Direct function calls create tight coupling. Events create loose coupling — the publisher doesn't know or care who's listening.
Custom Event Bus
React Integration
Browser Custom Events
When NOT to Use Events
- For parent-child communication (use props)
- When you need a return value (events are fire-and-forget)
- When ordering matters (events are inherently unordered)
- For simple, direct communication between two components