Trait relm4::MessageHandler

source ·
pub trait MessageHandler<ParentModel: Model> {
    type Msg;
    type Sender;

    // Required methods
    fn init(
        parent_model: &ParentModel,
        parent_sender: Sender<ParentModel::Msg>
    ) -> Self;
    fn send(&self, msg: Self::Msg);
    fn sender(&self) -> Self::Sender;
}
Expand description

A message handler that can be used in situations where a RelmWorker isn’t flexible enough.

Required Associated Types§

source

type Msg

The message type of this message handler.

source

type Sender

The sender type that can be used to send a message to a RelmMsgHandler.

Required Methods§

source

fn init( parent_model: &ParentModel, parent_sender: Sender<ParentModel::Msg> ) -> Self

Initialize this message handler.

source

fn send(&self, msg: Self::Msg)

Sends a message to the message handler.

source

fn sender(&self) -> Self::Sender

Get a sender for sending messages to this RelmMsgHandler.

Implementors§