O'Reilly logo

Mastering TypeScript by Nathan Rozentals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Domain Events Pattern

Most JavaScript frameworks have the concept of an event bus. An event bus is simply a method of publishing events to a global bus, so that other parts of your application that are subscribed to these events will receive a message, and be able to react to them. The use of an event-based architecture helps to decouple our applications, making them resilient to change and easier to test.

A Domain Event is an event that happens specific to our application domain. Something like "when an error occurs, log it to the console", or "when a menu button is clicked, change the sub-menu panel to reflect this option". A Domain Event can be raised anywhere in your code. Any class can register an event handler against this event, and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required