Trait relm::Widget
[−]
[src]
pub trait Widget where
Self: Clone + Sized,
Self::Container: Clone + IsA<Widget>,
Self::Msg: Clone + DisplayVariant, { type Container; type Model; type Msg; fn container(&self) -> &Self::Container; fn model() -> Self::Model; fn update(&mut self, event: Self::Msg, model: &mut Self::Model); fn view(relm: RemoteRelm<Self::Msg>, model: &Self::Model) -> Self; fn init_view(&self) { ... } fn on_add<W: IsA<Widget> + IsA<Object>>(&self, _parent: W) { ... } 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
type Container
The type of the containing widget.
type Model
The type of the model.
type Msg
The type of the messages sent to the update()
method.
Required Methods
fn container(&self) -> &Self::Container
Get the containing widget, i.e. the parent widget of the view.
fn model() -> Self::Model
Create the initial model.
fn update(&mut self, event: Self::Msg, model: &mut Self::Model)
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.
fn view(relm: RemoteRelm<Self::Msg>, model: &Self::Model) -> Self
Create the initial view.
Provided Methods
fn init_view(&self)
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.
fn on_add<W: IsA<Widget> + IsA<Object>>(&self, _parent: W)
Method called when the widget is added to its parent.
fn subscriptions(_relm: &Relm<Self::Msg>)
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 Future
s and Stream
s.
fn update_command(
_relm: &Relm<Self::Msg>,
_event: Self::Msg,
_model: &mut Self::Model
)
_relm: &Relm<Self::Msg>,
_event: Self::Msg,
_model: &mut Self::Model
)
Connect Future
s or Stream
s 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()
.