[][src]Struct mogwai::component::subscriber::Subscriber

pub struct Subscriber<Msg> { /* fields omitted */ }

A subscriber allows a component to subscribe to other components' messages without having explicit access to both Transmitter and Receiver. This allows the parent component to map child component messages into its own updates without needing its own transmitter. This is good because if send is called on a component's own ModelMsg transmitter during its Component::update it triggers a lock contetion. So a subscriber allows forwarding and wiring without enabling sending.

Implementations

impl<Msg: Clone + 'static> Subscriber<Msg>[src]

pub fn new(tx: &Transmitter<Msg>) -> Subscriber<Msg>[src]

Create a new Subscriber from a Transmitter.

pub fn subscribe_filter_map<ChildMsg, F>(&self, rx: &Receiver<ChildMsg>, f: F) where
    F: Fn(&ChildMsg) -> Option<Msg> + 'static, 
[src]

Subscribe to a receiver by forwarding messages from it using a filter map function.

pub fn subscribe_map<ChildMsg, F>(&self, rx: &Receiver<ChildMsg>, f: F) where
    F: Fn(&ChildMsg) -> Msg + 'static, 
[src]

Subscribe to a receiver by forwarding messages from it using a map function.

pub fn subscribe(&self, rx: &Receiver<Msg>)[src]

Subscribe to a receiver by forwarding messages from it.

pub fn send_async<F>(&self, f: F) where
    F: Future<Output = Msg> + 'static, 
[src]

Send a one-time asynchronous message.

NOTE

This is only available in the browser, being compiled for wasm32. On other targets this is a noop.

Trait Implementations

impl<Msg: Clone> Clone for Subscriber<Msg>[src]

Auto Trait Implementations

impl<Msg> !RefUnwindSafe for Subscriber<Msg>

impl<Msg> !Send for Subscriber<Msg>

impl<Msg> !Sync for Subscriber<Msg>

impl<Msg> Unpin for Subscriber<Msg>

impl<Msg> !UnwindSafe for Subscriber<Msg>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.