Defines a new typed event with a payload and tag.
A unique identifier for the event.
The payload type.
The tag for the event.
Optional
Optionally used to infer payload type (can use withPayload<T>()).
withPayload<T>()
The event that you can subscribe to and listen.
const event = defineEvent('user.created')// or with a payloadconst eventWithPayload = defineEvent('user.created', withPayload<{ id: number }>()) Copy
const event = defineEvent('user.created')// or with a payloadconst eventWithPayload = defineEvent('user.created', withPayload<{ id: number }>())
Defines a new typed event with a payload and tag.