[][src]Trait mogwai::component::Component

pub trait Component where
    Self: Sized + 'static,
    Self::ModelMsg: Clone,
    Self::ViewMsg: Clone,
    Self::DomNode: JsCast + AsRef<Node> + Clone
{ type ModelMsg; type ViewMsg; type DomNode; pub fn update(
        &mut self,
        msg: &Self::ModelMsg,
        tx_view: &Transmitter<Self::ViewMsg>,
        sub: &Subscriber<Self::ModelMsg>
    );
pub fn view(
        &self,
        tx: &Transmitter<Self::ModelMsg>,
        rx: &Receiver<Self::ViewMsg>
    ) -> ViewBuilder<Self::DomNode>; pub fn bind(&self, sub: &Subscriber<Self::ModelMsg>) { ... } }

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[src]

Message type used to drive component state updates.

type ViewMsg[src]

Message type used to drive view DOM patching.

type DomNode[src]

The type of web_sys::Node that represents the root of this component. ie HtmlElement, HtmlInputElement, etc.

Loading content...

Required methods

pub fn update(
    &mut self,
    msg: &Self::ModelMsg,
    tx_view: &Transmitter<Self::ViewMsg>,
    sub: &Subscriber<Self::ModelMsg>
)
[src]

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>
[src]

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.

Loading content...

Provided methods

pub fn bind(&self, sub: &Subscriber<Self::ModelMsg>)[src]

Used to perform any one-time binding from in scope Gizmos 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.

Loading content...

Implementors

impl<T, D> Component for SimpleComponent<T, D> where
    T: Clone + 'static,
    D: JsCast + AsRef<Node> + Clone + 'static, 
[src]

type ModelMsg = T

type ViewMsg = T

type DomNode = D

Loading content...