Skip to main content

publish_event

Function publish_event 

Source
pub fn publish_event(name: &str, data: &Value) -> Result<(), NodeAppError>
Expand description

Publish a domain event to the host event bus.

The event is queued asynchronously (fire-and-forget). The event name must be namespaced with the app name prefix (e.g. lightning.payment_received, my-app.user_created); the host rejects events whose name does not start with {app_name}..

§Errors

Returns NodeAppError::EventFailed if the host context is not available, the event name or data exceeds size limits (MAX_EVENT_NAME_LEN / MAX_EVENT_DATA_LEN), or the host rejects the event.