[−][src]Struct seed::App
Fields
init_cfg: Option<AppInitCfg<Ms, Mdl, ElC, GMs, dyn IntoAfterMount<Ms, Mdl, ElC, GMs>>>
Temporary app configuration that is removed after app begins running.
cfg: Rc<AppCfg<Ms, Mdl, ElC, GMs>>
App configuration available for the entire application lifetime.
data: Rc<AppData<Ms, Mdl>>
Mutable app state
Implementations
impl<Ms, Mdl, ElC: View<Ms> + 'static, GMs: 'static> App<Ms, Mdl, ElC, GMs>
[src]
We use a struct instead of series of functions, in order to avoid passing repetitive sequences of parameters.
pub fn build(
init: impl FnOnce(Url, &mut OrdersContainer<Ms, Mdl, ElC, GMs>) -> Init<Mdl> + 'static,
update: fn(_: Ms, _: &mut Mdl, _: &mut OrdersContainer<Ms, Mdl, ElC, GMs>),
view: fn(_: &Mdl) -> ElC
) -> AppBuilder<Ms, Mdl, ElC, GMs, MountPointInitInitAPI<UndefinedMountPoint, Box<dyn FnOnce(Url, &mut OrdersContainer<Ms, Mdl, ElC, GMs>) -> Init<Mdl>>>>
[src]
init: impl FnOnce(Url, &mut OrdersContainer<Ms, Mdl, ElC, GMs>) -> Init<Mdl> + 'static,
update: fn(_: Ms, _: &mut Mdl, _: &mut OrdersContainer<Ms, Mdl, ElC, GMs>),
view: fn(_: &Mdl) -> ElC
) -> AppBuilder<Ms, Mdl, ElC, GMs, MountPointInitInitAPI<UndefinedMountPoint, Box<dyn FnOnce(Url, &mut OrdersContainer<Ms, Mdl, ElC, GMs>) -> Init<Mdl>>>>
Use builder
with AppBuilder::{after_mount, before_mount}
instead.
pub fn builder(
update: fn(_: Ms, _: &mut Mdl, _: &mut OrdersContainer<Ms, Mdl, ElC, GMs>),
view: fn(_: &Mdl) -> ElC
) -> AppBuilder<Ms, Mdl, ElC, GMs, UndefinedInitAPI>
[src]
update: fn(_: Ms, _: &mut Mdl, _: &mut OrdersContainer<Ms, Mdl, ElC, GMs>),
view: fn(_: &Mdl) -> ElC
) -> AppBuilder<Ms, Mdl, ElC, GMs, UndefinedInitAPI>
Creates a new AppBuilder
instance. It's the standard way to create a Seed app.
Then you can call optional builder methods like routes
or sink
.
And you have to call method build_and_start
to build and run a new App
instance.
NOTE: If your Model
doesn't implement Default
, you have to call builder method after_mount
.
Example
fn update(msg: Msg, model: &mut Model, _orders: &mut impl Orders<Msg, GMsg>) { match msg { Msg::Clicked => model.clicks += 1, } } fn view(model: &Model) -> impl View<Msg> { vec![ button![ format!("Clicked: {}", model.clicks), simple_ev(Ev::Click, Msg::Clicked), ], ] } App::builder(update, view)
pub fn setup_window_listeners(&self)
[src]
pub fn run(self) -> Self
[src]
Please use AppBuilder.build_and_start
instead
App initialization: Collect its fundamental components, setup, and perform an initial render.
pub fn update(&self, message: Ms)
[src]
This runs whenever the state is changed, ie the user-written update function is called. It updates the state, and any DOM elements affected by this change. todo this is where we need to compare against differences and only update nodes affected by the state change.
We re-create the whole virtual dom each time (Is there a way around this? Probably not without knowing what vars the model holds ahead of time), but only edit the rendered, web_sys dom for things that have been changed. We re-render the virtual DOM on every change, but (attempt to) only change the actual DOM, via web_sys, when we need. The model stored in inner is the old model; updated_model is a newly-calculated one.
pub fn sink(&self, g_msg: GMs)
[src]
pub fn process_cmd_and_msg_queue(&self, queue: VecDeque<Effect<Ms, GMs>>)
[src]
pub fn add_message_listener<F>(&self, listener: F) where
F: Fn(&Ms) + 'static,
[src]
F: Fn(&Ms) + 'static,
Trait Implementations
impl<Ms, Mdl, ElC: View<Ms>, GMs> Clone for App<Ms, Mdl, ElC, GMs>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Ms: 'static, Mdl: 'static, ElC: View<Ms>, GMs> Debug for App<Ms, Mdl, ElC, GMs>
[src]
Auto Trait Implementations
impl<Ms, Mdl, ElC, GMs = UndefinedGMsg> !RefUnwindSafe for App<Ms, Mdl, ElC, GMs>
impl<Ms, Mdl, ElC, GMs = UndefinedGMsg> !Send for App<Ms, Mdl, ElC, GMs>
impl<Ms, Mdl, ElC, GMs = UndefinedGMsg> !Sync for App<Ms, Mdl, ElC, GMs>
impl<Ms, Mdl, ElC, GMs> Unpin for App<Ms, Mdl, ElC, GMs> where
ElC: Unpin,
GMs: Unpin,
Mdl: Unpin,
Ms: Unpin,
ElC: Unpin,
GMs: Unpin,
Mdl: Unpin,
Ms: Unpin,
impl<Ms, Mdl, ElC, GMs = UndefinedGMsg> !UnwindSafe for App<Ms, Mdl, ElC, GMs>
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,
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,