Function message_worker::non_blocking::listen[][src]

pub fn listen<Ctx, CtxFactory, Source, Event, HandleEventFuture>(
    source: Source,
    context_factory: CtxFactory,
    handle_event: fn(_: Arc<Ctx>, _: Event) -> HandleEventFuture
) -> JoinHandle<()> where
    Ctx: ThreadSafeContext,
    CtxFactory: FnOnce() -> Ctx + Send + 'static,
    Source: Stream<Item = Event> + Unpin + Send + 'static,
    Event: Send + 'static,
    HandleEventFuture: Future<Output = Result<()>> + Send + 'static, 
Expand description

Creates a listener with the default error handler on its own system thread. It is safe to work with non-sync and non-send data in this listener. The callback (handle_event) will be invoked whenever a new item from the source stream is emitted. The context_factory is a closure you must provide that returns the initial state for the listener.