Fire‑and‑Forget Semantics
PostboyGenericMessage represents a one‑way broadcast. The publisher fires a message and continues immediately; subscribers react independently and do not return a value.
1. How it differs from callback messages
Aspect | Generic message | Callback message |
|---|---|---|
Direction | Publisher → Subscribers | Requester → Handler → Requester |
Return value | None | Typed result via |
Lifetime | Delivered to all current subscribers | One handler; one result emission |
Contract |
|
|
2. The flow
No subscriber is required. If none exist, the message is simply discarded.
3. Code example (framework‑agnostic)
Message definition
Registration (once, during startup)
Subscriber (e.g. a cleanup service)
Subscriber (e.g. a notification service)
Publisher (e.g. an authentication service)
4. No response, no waiting
The publisher does not receive an observable back from fire. The call is synchronous from the publisher’s perspective. Any asynchronous work inside subscribers runs independently.
5. When no subscriber exists
Firing a generic message with zero subscribers is a valid, safe operation. The message is discarded, no error is thrown. This makes it safe to publish optional events (e.g., debugging, telemetry) without guarding against empty subscriber lists.
Key points
Fire‑and‑forget: the publisher sends the message and forgets about it.
No return value: generic messages do not have
msg.finish(); they are pure notifications.Decoupling: the publisher never knows how many subscribers exist or what they do.
Use for domain events, notifications, state broadcasts — any situation where the publisher does not need a direct answer.