[−][src]Trait mogwai::component::Component
Defines a component with distinct input (model update) and output (view update) messages.
See the module level documentation for more details.
Associated Types
type ModelMsg
Message type used to drive component state updates.
type ViewMsg
Message type used to drive view DOM patching.
type DomNode
The type of web_sys::Node
that represents the root of this component.
ie HtmlElement, HtmlInputElement, etc.
Required methods
pub fn update(
&mut self,
msg: &Self::ModelMsg,
tx_view: &Transmitter<Self::ViewMsg>,
sub: &Subscriber<Self::ModelMsg>
)
&mut self,
msg: &Self::ModelMsg,
tx_view: &Transmitter<Self::ViewMsg>,
sub: &Subscriber<Self::ModelMsg>
)
Update this component in response to any received model messages. This is essentially the component's fold function.
pub fn view(
&self,
tx: &Transmitter<Self::ModelMsg>,
rx: &Receiver<Self::ViewMsg>
) -> ViewBuilder<Self::DomNode>
&self,
tx: &Transmitter<Self::ModelMsg>,
rx: &Receiver<Self::ViewMsg>
) -> ViewBuilder<Self::DomNode>
Produce this component's view using a Transmitter
of model input messages
and a Receiver
of view output messages.
Model messages flow from the view into the update function. View messages flow from the update function to the view.
Provided methods
pub fn bind(&self, sub: &Subscriber<Self::ModelMsg>)
Used to perform any one-time binding from in scope Gizmo
s to this component's subscriber.
This should be used to bind sub-component view messages into this parent component's model messages in order to receive updates from child components. The default implementation is a noop.
This function will be called only once, after a Gizmo
is converted from the
type implementing Component
.
Implementors
impl<T, D> Component for SimpleComponent<T, D> where
T: Clone + 'static,
D: JsCast + AsRef<Node> + Clone + 'static,
[src]
T: Clone + 'static,
D: JsCast + AsRef<Node> + Clone + 'static,
type ModelMsg = T
type ViewMsg = T
type DomNode = D
pub fn update(
&mut self,
msg: &T,
tx_view: &Transmitter<T>,
_sub: &Subscriber<T>
)
[src]
&mut self,
msg: &T,
tx_view: &Transmitter<T>,
_sub: &Subscriber<T>
)