Trait relm::Widget [] [src]

pub trait Widget where
    Self: Clone,
    Self::Root: Clone + IsA<Widget>,
    Self::Msg: Clone + DisplayVariant
{ type Model; type ModelParam: Sized; type Msg; type Root; fn model(param: Self::ModelParam) -> Self::Model; fn root(&self) -> &Self::Root; fn update(&mut self, event: Self::Msg, model: &mut Self::Model); fn view(relm: &RemoteRelm<Self>, model: &Self::Model) -> Self; fn init_view(&self) { ... } fn on_add<W: IsA<Widget> + IsA<Object>>(&self, _parent: W) { ... } fn run(model_param: Self::ModelParam) -> Result<(), ()>
    where
        Self: 'static,
        Self::Model: Clone + Send,
        Self::ModelParam: Default,
        Self::Msg: Send
, { ... } fn subscriptions(_relm: &Relm<Self::Msg>) { ... } fn update_command(
        _relm: &Relm<Self::Msg>,
        _event: Self::Msg,
        _model: &mut Self::Model
    ) { ... } }

Trait to implement to manage widget's events.

Associated Types

The type of the model.

The type of the parameter of the model() function used to initialize the model.

The type of the messages sent to the update() method.

The type of the root widget.

Required Methods

Create the initial model.

Get the root widget of the view.e. the root widget of the view.

Method called when a message is received from an event.

Note

This method is called in the GTK+ thread, so that you can update widgets.

Create the initial view.

Provided Methods

Update the view after it is initially created. This method is only useful when using the #[widget] attribute, because when not using it, you can use the view() method instead.

Method called when the widget is added to its parent.

Create the window from this widget and start the main loop.

Connect the subscriptions. Subscriptions are Future/Stream that are spawn when the widget is created.

Note

This method is called in the tokio thread, so that you can spawn Futures and Streams.

Connect Futures or Streams when receiving an event.

Warning

This method is executed in the tokio thread: hence, you must spawn any futures in this method, not in Widget::update().

Implementors