pub trait EventDispatcher<Ctx: Client> {
    // Required method
    fn add_event_handler<M: Any>(
        &mut self,
        event_stream: impl Stream<Item = M> + 'static,
        handler: impl EventHandler<Ctx, Message = M> + 'static
    );
}
Expand description

Event dispatcher

Use this trait to register an async function to be called whenever a new event is received from an event source.

See also EventDispatcher for a reference implementation of this trait.

Required Methods§

source

fn add_event_handler<M: Any>( &mut self, event_stream: impl Stream<Item = M> + 'static, handler: impl EventHandler<Ctx, Message = M> + 'static )

Register an event handler

This takes a stream of events, and an event handler, which defines an async function that will be called for each of the events received from the stream.

Arguments
  • event_source: A stream of items. Each item is an event. See EventSource, which is how event streams are created.
  • handler: The event handler.

Implementors§

source§

impl<Ctx: Client + 'static> EventDispatcher<Ctx> for EventDispatcher<Ctx>