Skip to main content

EventBus

Trait EventBus 

Source
pub trait EventBus: Send + Sync {
    // Required methods
    fn emit(&self, event: &str, payload: Value) -> Result<(), PluginError>;
    fn subscribe(
        &self,
        event: AppEvent,
        handler: Box<dyn Fn(Value) + Send + Sync>,
    ) -> SubscriptionToken;
    fn unsubscribe(&self, token: SubscriptionToken);
}

Required Methods§

Source

fn emit(&self, event: &str, payload: Value) -> Result<(), PluginError>

Emit a plugin-scoped event. Full event name on the wire: plugin:{plugin_id}:{event}

Source

fn subscribe( &self, event: AppEvent, handler: Box<dyn Fn(Value) + Send + Sync>, ) -> SubscriptionToken

Subscribe to a well-known app event. Returns a token for unsubscribing.

Source

fn unsubscribe(&self, token: SubscriptionToken)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§