Skip to main content

AppEventEmitter

Trait AppEventEmitter 

Source
pub trait AppEventEmitter: Send + Sync {
    // Required method
    fn emit(&self, event: AppEvent);
}
Expand description

Trait for emitting application events.

This abstraction keeps event plumbing consistent across domains and prevents channel types from becoming part of the public API surface.

§Implementations

  • NoopEmitter - For tests and CLI contexts that don’t need events
  • Adapter-specific implementations (Tauri, Axum SSE, etc.)

§Example

// In a service
fn start_server(&self, emitter: Arc<dyn AppEventEmitter>) {
    // ... start server logic ...
    emitter.emit(AppEvent::server_started(model_id, model_name, port));
}

Required Methods§

Source

fn emit(&self, event: AppEvent)

Emit an application event.

Implementations should handle the event asynchronously or buffer it. This method should not block.

Implementors§