[][src]Trait seed::orders::Orders

pub trait Orders<Ms: 'static, GMs = ()> {
    type AppMs: 'static;
    type Mdl: 'static;
    type ElC: View<Self::AppMs> + 'static;
    fn proxy<ChildMs: 'static>(
        &mut self,
        f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
    ) -> OrdersProxy<ChildMs, Self::AppMs, Self::Mdl, Self::ElC, GMs>;
fn render(&mut self) -> &mut Self;
fn force_render_now(&mut self) -> &mut Self;
fn skip(&mut self) -> &mut Self;
fn send_msg(&mut self, msg: Ms) -> &mut Self;
fn perform_cmd<C>(&mut self, cmd: C) -> &mut Self
    where
        C: Future<Item = Ms, Error = Ms> + 'static
;
fn send_g_msg(&mut self, g_msg: GMs) -> &mut Self;
fn perform_g_cmd<C>(&mut self, g_cmd: C) -> &mut Self
    where
        C: Future<Item = GMs, Error = GMs> + 'static
;
fn clone_app(&self) -> App<Self::AppMs, Self::Mdl, Self::ElC, GMs>;
fn msg_mapper(&self) -> Box<dyn Fn(Ms) -> Self::AppMs>; }

Associated Types

type AppMs: 'static

type Mdl: 'static

type ElC: View<Self::AppMs> + 'static

Loading content...

Required methods

fn proxy<ChildMs: 'static>(
    &mut self,
    f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
) -> OrdersProxy<ChildMs, Self::AppMs, Self::Mdl, Self::ElC, GMs>

Automatically map message type. It allows you to pass Orders into child module.

Example

Msg::Child(child_msg) => {
   child::update(child_msg, &mut model.child, &mut orders.proxy(Msg::Child));
}

fn render(&mut self) -> &mut Self

Schedule web page rerender after model update. It's the default behaviour.

fn force_render_now(&mut self) -> &mut Self

Force web page to rerender immediately after model update.

fn skip(&mut self) -> &mut Self

Don't rerender web page after model update.

fn send_msg(&mut self, msg: Ms) -> &mut Self

Call function update with the given msg after model update. You can call this function more times - messages will be sent in the same order.

fn perform_cmd<C>(&mut self, cmd: C) -> &mut Self where
    C: Future<Item = Ms, Error = Ms> + 'static, 

Schedule given future cmd to be executed after model update. Result is send to function update. You can call this function more times - futures will be scheduled in the same order.

Example

fn write_emoticon_after_delay() -> impl Future<Item=Msg, Error=Msg> {
   TimeoutFuture::new(2_000)
       .map(|_| Msg::WriteEmoticon)
       .map_err(|_| Msg::TimeoutError)
}
orders.perform_cmd(write_emoticon_after_delay());

fn send_g_msg(&mut self, g_msg: GMs) -> &mut Self

Similar to send_msg, but calls function sink with the given global message.

fn perform_g_cmd<C>(&mut self, g_cmd: C) -> &mut Self where
    C: Future<Item = GMs, Error = GMs> + 'static, 

Similar to perform_cmd, but result is send to function sink.

fn clone_app(&self) -> App<Self::AppMs, Self::Mdl, Self::ElC, GMs>

Get app instance. Cloning is cheap because App contains only Rc fields.

fn msg_mapper(&self) -> Box<dyn Fn(Ms) -> Self::AppMs>

Get function which maps module's Msg to app's (root's) one.

Example

let (app, msg_mapper) = (orders.clone_app(), orders.msg_mapper());
app.update(msg_mapper(Msg::AMessage));
Loading content...

Implementors

impl<'a, Ms: 'static, AppMs: 'static, Mdl, ElC: View<AppMs> + 'static, GMs> Orders<Ms, GMs> for OrdersProxy<'a, Ms, AppMs, Mdl, ElC, GMs>[src]

type AppMs = AppMs

type Mdl = Mdl

type ElC = ElC

impl<Ms: 'static, Mdl, ElC: View<Ms> + 'static, GMs> Orders<Ms, GMs> for OrdersContainer<Ms, Mdl, ElC, GMs>[src]

type AppMs = Ms

type Mdl = Mdl

type ElC = ElC

Loading content...