-
-
Notifications
You must be signed in to change notification settings - Fork 56
component
Jovansonlee Cesar edited this page Oct 13, 2021
·
1 revision
You can write an application without the need to use for Component. This is totally optional, but it serves as a helper trait for parts of your application to have some consistency.
pub trait Component<MSG, XMSG> {
fn update(&mut self, msg: MSG) -> Effects<MSG, XMSG>;
fn view(&self) -> Node<MSG>;
}
impl Component<Msg, XMSG> for FieldWidget<Msg,XMSG>{
fn update(&mut self, msg: Msg) -> Effects<Msg, XMSG>{
// --snip--
}
fn view(&self) -> Node<Msg>{
// --snip
}
}
Effects is a way to contain Msg to be processed in the application that mounts it.