[−][src]Struct mogwai::gizmo::SimpleComponent
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]
F: Fn(&Transmitter<T>, &Receiver<T>) -> ViewBuilder<D> + 'static,
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]
T: Clone + 'static,
D: JsCast + AsRef<Node> + Clone + 'static,
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
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>
)
pub fn view(&self, tx: &Transmitter<T>, rx: &Receiver<T>) -> ViewBuilder<D>
[src]
pub fn bind(&self, sub: &Subscriber<Self::ModelMsg>)
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,