Subscribing in Multiple Components
When a single domain event affects several parts of the UI, each component subscribes to the same PostboyGenericMessage independently.
None of them know about each other, and the publisher remains completely unchanged.
1. The event: CallStartedEvent
This event is published when a new call arrives. It carries all the information needed by the UI.
The message is already registered somewhere central (for example, in CallRoutingService), so components only need to subscribe.
2. Header component: show an alert badge
The header displays a badge when a call is active.
3. Customer profile widget: show caller details
The customer profile widget uses the same event to display the caller’s name and VIP status.
4. Call status panel: start call timer
A separate panel starts a timer as soon as the call arrives.
5. Toast center: show a notification
Even the global toast notification service listens to the same event.
Key points
A single
fire(new CallStartedEvent(call))updates four different UI areas automatically.Each component subscribes in its own constructor and reacts with its own logic — no cross‑component wiring is needed.
Adding a fifth subscriber (e.g., a logging panel) requires only a new subscription; nothing else changes.
This pattern eliminates
@Inputchains and shared state services that would otherwise tangle the components together.