Events
An event is a message emitted by the system when "something" happens. Again this could be a technical task being completed such as a DatabaseBackedUp, LoadBalancerScaledOut or as a result of changes in your business CreditCardCharged, UserRegistered, PackageShipped.
Use natural language in the past-tense when naming an event since it represents a historic fact has taken place. This also helps improve the readability of your code, as the history of your application can be discussed in terms of the order of events.
Events are class definitions that extend from
Event
, eg:import { Event } from '@node-ts/bus-messages'
export class CreditCardCharged extends Event {
/**
* A unique name that identifies the message. This should be done in namespace style syntax,
* ie: organisation/domain/event-name
*/
$name = 'my-app/accounts/credit-card-charged'