[][src]Struct mogwai::gizmo::SimpleComponent

pub struct SimpleComponent<T, D: IsDomNode>(_);

A simple component made from a BuilderFn.

Any function that takes a transmitter and receiver of the same type and returns a ViewBuilder can be made into a component that holds no internal state. It forwards all of its incoming messages to its view.

extern crate mogwai;
use mogwai::prelude::*;

let component = Gizmo::from(SimpleComponent::new(
    |tx: &Transmitter<()>, rx: &Receiver<()>| -> ViewBuilder<HtmlElement> {
        builder!{
            <button style="pointer" on:click=tx.contra_map(|_| ())>
                {("Click me", rx.branch_map(|()| "Clicked!".to_string()))}
            </button>
        }
    }
));

Implementations

impl<T, D: IsDomNode> SimpleComponent<T, D>[src]

pub fn new<F>(f: F) -> Self where
    F: Fn(&Transmitter<T>, &Receiver<T>) -> ViewBuilder<D> + 'static, 
[src]

Create a new SimpleCopmonent form a static Fn closure.

Trait Implementations

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

type ModelMsg = T

Message type used to drive component state updates.

type ViewMsg = T

Message type used to drive view DOM patching.

type DomNode = D

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

Auto Trait Implementations

impl<T, D> !RefUnwindSafe for SimpleComponent<T, D>

impl<T, D> !Send for SimpleComponent<T, D>

impl<T, D> !Sync for SimpleComponent<T, D>

impl<T, D> Unpin for SimpleComponent<T, D>

impl<T, D> !UnwindSafe for SimpleComponent<T, D>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.