[−][src]Trait seed::app::orders::Orders
Associated Types
Loading content...Required methods
fn proxy<ChildMs: 'static>(
&mut self,
f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
) -> OrdersProxy<ChildMs, Self::AppMs, Self::Mdl, Self::INodes, GMs>
&mut self,
f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
) -> OrdersProxy<ChildMs, Self::AppMs, Self::Mdl, Self::INodes, 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 notify(&mut self, message: impl Any + Clone) -> &mut Self
Notify all subscription handlers that listen for messages with the message
's type.
Note: Seed's native subscriptions / messages
can be also sent - e.g.
orders.notify(subs::UrlRequested::new(url))
.
The most is ignored by the Seed's runtime, but some of them are processed and
trigger side-effects - e.g. simulate <a>
link click by sending subs::UrlRequested
.
Example
orders.notify(counter::DoReset); orders.notify("Hello!"); ... orders.subscribe(Msg::Reset); // `Msg::Reset(counter::DoReset)` orders.subscribe(|greeting: &'static str| log!(greeting));
Note:: All notifications are pushed to the queue - i.e. update
function is NOT called immediately.
fn send_msg(&mut self, msg: Ms) -> &mut Self
Invoke function update
with the given msg
.
Example
orders.msg(Msg::Increment);
Note:: All msg
s are pushed to the queue - i.e. update
function is NOT called immediately.
fn perform_cmd<MsU: 'static>(
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> &mut Self
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> &mut Self
Execute cmd
and send its output (if it's Msg
) to update
function.
Output has to be Msg
, Option<Msg>
or ()
.
Example
orders.perform_cmd(cmds::timeout(2000, || Msg::OnTimeout)); orders.perform_cmd(async { log!("Hello!") });
Note:: Use the alternative perform_cmd_with_handle
to control cmd
's lifetime.
Panics
Panics when the output isn't Msg
, Option<Msg>
or ()
.
(It will be changed to a compile-time error).
#[must_use = "cmd is aborted on its handle drop"]fn perform_cmd_with_handle<MsU: 'static>(
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> CmdHandle
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> CmdHandle
Execute given cmd
and send its output (if it's Msg
) to update
function.
- Returns
CmdHandle
that you should save to yourModel
. Thecmd
is aborted on the handle drop.
Output has to be Msg
, Option<Msg>
or ()
.
Example
let timeout_handle = orders.perform_cmd_with_handle(cmds::timeout(2000, || Msg::OnTimeout)); let cmd_handle = orders.perform_cmd_with_handle(async { log!("Hello!") });
Panics
Panics when the output isn't Msg
, Option<Msg>
or ()
.
(It will be changed to a compile-time error).
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(
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> &mut Self
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> &mut Self
Similar to perform_cmd
, but result is send to function sink
.
#[must_use = "cmd is aborted on its handle drop"]fn perform_g_cmd_with_handle(
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> CmdHandle
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> CmdHandle
Similar to perform_g_cmd
, but result is send to function sink
.
- Returns
CmdHandle
that you should save to yourModel
.cmd
is aborted on the handle drop.
fn clone_app(&self) -> App<Self::AppMs, Self::Mdl, Self::INodes, GMs>
Get app instance. Cloning is cheap because App
contains only Rc
fields.
fn msg_mapper(&self) -> Box<dyn Fn(Ms) -> Self::AppMs>
Get the function that 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));
fn after_next_render<MsU: 'static>(
&mut self,
callback: impl FnOnce(RenderInfo) -> MsU + 'static
) -> &mut Self
&mut self,
callback: impl FnOnce(RenderInfo) -> MsU + 'static
) -> &mut Self
Register the callback that will be executed after the next render.
Callback's only parameter is RenderInfo
- it has fields timestamp
and timestamp_delta
.
timestamp_delta
is the difference between the old render timestamp and the new one
and it has value None
if it's the first rendering.
- It's useful when you want to use DOM API or make animations.
- You can call this function multiple times - callbacks will be executed in the same order.
- Callback has to return
Msg
,Option<Msg>
or()
.
Note: performance.now() is used under the hood to get timestamps.
Panics
Panics when the handler doesn't return Msg
, Option<Msg>
or ()
.
(It will be changed to a compile-time error).
fn subscribe<MsU: 'static, SubMs: 'static + Clone>(
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> &mut Self
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> &mut Self
Subscribe for messages with the handler
s input type.
Handler has to return Msg
, Option<Msg>
or ()
.
Example
orders.subscribe(Msg::Reset); // `Msg::Reset(counter::DoReset)` orders.subscribe(|greeting: &'static str| log!(greeting)); orders.subscribe(Msg::UrlChanged) // `update(... Msg::UrlChanged(subs::UrlChanged(url)) =>` ... orders.notify(counter::DoReset); orders.notify("Hello!");
Note:: Use the alternative subscribe_with_handle
to control sub
's lifetime.
Panics
Panics when the handler doesn't return Msg
, Option<Msg>
or ()
.
(It will be changed to a compile-time error).
#[must_use = "subscription is cancelled on its handle drop"]fn subscribe_with_handle<MsU: 'static, SubMs: 'static + Clone>(
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> SubHandle
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> SubHandle
Subscribe for messages with the handler
s input type.
- Returns
SubHandle
that you should save to yourModel
. Thesub
is cancelled on the handle drop.
Handler has to return Msg
, Option<Msg>
or ()
.
Example
let sub_handle = orders.subscribe_with_handle(Msg::Reset); // `Msg::Reset(counter::DoReset)` orders.subscribe_with_handle(|greeting: &'static str| log!(greeting)); let url_changed_handle = orders.subscribe_with_handle(Msg::UrlChanged) // `update(... Msg::UrlChanged(subs::UrlChanged(url)) =>` ... orders.notify(counter::DoReset); orders.notify("Hello!");
Panics
Panics when the handler doesn't return Msg
, Option<Msg>
or ()
.
(It will be changed to a compile-time error).
fn stream<MsU: 'static>(
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> &mut Self
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> &mut Self
Stream Msg
, Option<Msg>
or ()
.
Example
orders.stream(streams::interval(1000, || Msg::OnTick)); orders.stream(streams::window_event(Ev::Resize, |_| Msg::OnResize));
Note:: Use the alternative stream_with_handle
to control stream
's lifetime.
Panics
Panics when the handler doesn't return Msg
, Option<Msg>
or ()
.
(It will be changed to a compile-time error).
#[must_use = "stream is stopped on its handle drop"]fn stream_with_handle<MsU: 'static>(
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> StreamHandle
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> StreamHandle
Stream Msg
, Option<Msg>
or ()
.
- Returns
StreamHandle
that you should save to yourModel
. Thestream
is cancelled on the handle drop.
Example
let timer_handler = orders.stream_with_handle(streams::interval(1000, || Msg::OnTick)); let stream_handler = orders.stream_with_handle(streams::window_event(Ev::Resize, |_| Msg::OnResize));
Panics
Panics when the handler doesn't return Msg
, Option<Msg>
or ()
.
(It will be changed to a compile-time error).
Provided methods
fn clone_base_path(&self) -> Rc<Vec<String>>
Cheap clone base path loaded from element <base href="base/path">
.
Returns empty Vec
if there is no base
element in your HTML
or there were problems with parsing.
Implementors
impl<'a, Ms: 'static, AppMs: 'static, Mdl, INodes: IntoNodes<AppMs> + 'static, GMs> Orders<Ms, GMs> for OrdersProxy<'a, Ms, AppMs, Mdl, INodes, GMs>
[src]
type AppMs = AppMs
type Mdl = Mdl
type INodes = INodes
fn proxy<ChildMs: 'static>(
&mut self,
f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
) -> OrdersProxy<ChildMs, AppMs, Mdl, INodes, GMs>
[src]
&mut self,
f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
) -> OrdersProxy<ChildMs, AppMs, Mdl, INodes, GMs>
fn render(&mut self) -> &mut Self
[src]
fn force_render_now(&mut self) -> &mut Self
[src]
fn skip(&mut self) -> &mut Self
[src]
fn notify(&mut self, message: impl Any + Clone) -> &mut Self
[src]
fn send_msg(&mut self, msg: Ms) -> &mut Self
[src]
fn perform_cmd<MsU: 'static>(
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> &mut Self
[src]
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> &mut Self
fn perform_cmd_with_handle<MsU: 'static>(
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> CmdHandle
[src]
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> CmdHandle
fn send_g_msg(&mut self, g_msg: GMs) -> &mut Self
[src]
fn perform_g_cmd(
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> &mut Self
[src]
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> &mut Self
fn perform_g_cmd_with_handle(
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> CmdHandle
[src]
&mut self,
g_cmd: impl Future<Output = GMs> + 'static
) -> CmdHandle
fn clone_app(&self) -> App<Self::AppMs, Self::Mdl, Self::INodes, GMs>
[src]
fn msg_mapper(&self) -> Box<dyn Fn(Ms) -> Self::AppMs>
[src]
fn after_next_render<MsU: 'static>(
&mut self,
callback: impl FnOnce(RenderInfo) -> MsU + 'static
) -> &mut Self
[src]
&mut self,
callback: impl FnOnce(RenderInfo) -> MsU + 'static
) -> &mut Self
fn subscribe<MsU: 'static, SubMs: 'static + Clone>(
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> &mut Self
[src]
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> &mut Self
fn subscribe_with_handle<MsU: 'static, SubMs: 'static + Clone>(
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> SubHandle
[src]
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> SubHandle
fn stream<MsU: 'static>(
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> &mut Self
[src]
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> &mut Self
fn stream_with_handle<MsU: 'static>(
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> StreamHandle
[src]
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> StreamHandle
impl<Ms: 'static, Mdl, INodes: IntoNodes<Ms> + 'static, GMs: 'static> Orders<Ms, GMs> for OrdersContainer<Ms, Mdl, INodes, GMs>
[src]
type AppMs = Ms
type Mdl = Mdl
type INodes = INodes
fn proxy<ChildMs: 'static>(
&mut self,
f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
) -> OrdersProxy<ChildMs, Ms, Mdl, INodes, GMs>
[src]
&mut self,
f: impl FnOnce(ChildMs) -> Ms + 'static + Clone
) -> OrdersProxy<ChildMs, Ms, Mdl, INodes, GMs>
fn render(&mut self) -> &mut Self
[src]
fn force_render_now(&mut self) -> &mut Self
[src]
fn skip(&mut self) -> &mut Self
[src]
fn notify(&mut self, message: impl Any + Clone) -> &mut Self
[src]
fn send_msg(&mut self, msg: Ms) -> &mut Self
[src]
fn perform_cmd<MsU: 'static>(
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> &mut Self
[src]
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> &mut Self
fn perform_cmd_with_handle<MsU: 'static>(
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> CmdHandle
[src]
&mut self,
cmd: impl Future<Output = MsU> + 'static
) -> CmdHandle
fn send_g_msg(&mut self, g_msg: GMs) -> &mut Self
[src]
fn perform_g_cmd(
&mut self,
cmd: impl Future<Output = GMs> + 'static
) -> &mut Self
[src]
&mut self,
cmd: impl Future<Output = GMs> + 'static
) -> &mut Self
fn perform_g_cmd_with_handle(
&mut self,
cmd: impl Future<Output = GMs> + 'static
) -> CmdHandle
[src]
&mut self,
cmd: impl Future<Output = GMs> + 'static
) -> CmdHandle
fn clone_app(&self) -> App<Self::AppMs, Self::Mdl, Self::INodes, GMs>
[src]
fn msg_mapper(&self) -> Box<dyn Fn(Ms) -> Self::AppMs>
[src]
fn after_next_render<MsU: 'static>(
&mut self,
callback: impl FnOnce(RenderInfo) -> MsU + 'static
) -> &mut Self
[src]
&mut self,
callback: impl FnOnce(RenderInfo) -> MsU + 'static
) -> &mut Self
fn subscribe<MsU: 'static, SubMs: 'static + Clone>(
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> &mut Self
[src]
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> &mut Self
fn subscribe_with_handle<MsU: 'static, SubMs: 'static + Clone>(
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> SubHandle
[src]
&mut self,
handler: impl FnOnce(SubMs) -> MsU + Clone + 'static
) -> SubHandle
fn stream<MsU: 'static>(
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> &mut Self
[src]
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> &mut Self
fn stream_with_handle<MsU: 'static>(
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> StreamHandle
[src]
&mut self,
stream: impl Stream<Item = MsU> + 'static
) -> StreamHandle