Function ambient_api::message::subscribe
source · pub fn subscribe<R, T>(
callback: impl FnMut(MessageContext, T) -> R + 'static
) -> Listenerwhere
R: CallbackReturn,
T: Message,
Expand description
Subscribes to a message.
To unsubscribe from a message, call Listener::stop on the returned Listener, or on the MessageContext that is passed to the callback.