[−][src]Struct mogwai::gizmo::Gizmo
A user interface component that can spawn views.
Fields
trns: Transmitter<T::ModelMsg>
This gizmo's Component::ModelMsg
transmitter.
Sending on this Transmitter
causes its Component::update
function to run.
recv: Receiver<T::ViewMsg>
This gizmo's Component::ViewMsg
receiver.
Clones of this receiver are owned by all of this gizmo's views.
state: Rc<RefCell<T>>
This gizmo's internal state.
Implementations
impl<T> Gizmo<T> where
T: Component + 'static,
T::ViewMsg: Clone,
T::DomNode: JsCast + AsRef<Node> + Clone,
[src]
T: Component + 'static,
T::ViewMsg: Clone,
T::DomNode: JsCast + AsRef<Node> + Clone,
pub fn from_parts(
init: T,
tx_in: Transmitter<T::ModelMsg>,
rx_out: Receiver<T::ViewMsg>
) -> Self
[src]
init: T,
tx_in: Transmitter<T::ModelMsg>,
rx_out: Receiver<T::ViewMsg>
) -> Self
Create a new Gizmo
from an initial state using
a view and the Transmitter
+ Receiver
used to
create that view.
pub fn new(init: T) -> Gizmo<T>
[src]
pub fn view_builder(&self) -> ViewBuilder<T::DomNode>
[src]
Use the Gizmo to spawn a ViewBuilder<T::DomNode>
.
This allows you to send the builder (or subsequent view) somewhere else while still
maintaining the ability to update the view from afar.
pub fn send(&self, msg: &T::ModelMsg)
[src]
Update the component with the given message. This how a parent component communicates down to its child components.
pub fn with_state<F, N>(&self, f: F) -> N where
F: Fn(&T) -> N,
[src]
F: Fn(&T) -> N,
Access the underlying state.
pub fn set_state(&mut self, t: T)
[src]
Set this gizmo's state.
This silently updates the state and doesn't trigger any messages and does not update the view.
pub fn state_ref(&self) -> Ref<'_, T>
[src]
Borrow a reference to the inner state.
Trait Implementations
impl<T> From<Gizmo<T>> for View<<T as Component>::DomNode> where
T: Component,
<T as Component>::DomNode: JsCast + AsRef<Node>,
[src]
T: Component,
<T as Component>::DomNode: JsCast + AsRef<Node>,
impl<T: Component> From<T> for Gizmo<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Gizmo<T>
impl<T> !Send for Gizmo<T>
impl<T> !Sync for Gizmo<T>
impl<T> Unpin for Gizmo<T>
impl<T> !UnwindSafe for Gizmo<T>
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<!> for 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>,