[][src]Struct seed::app::App

pub struct App<Ms, Mdl, ElC, GMs = UndefinedGMsg> where
    Ms: 'static,
    Mdl: 'static,
    ElC: View<Ms>, 
{ pub init_cfg: Option<AppInitCfg<Ms, Mdl, ElC, GMs, dyn IntoAfterMount<Ms, Mdl, ElC, GMs>>>, pub cfg: Rc<AppCfg<Ms, Mdl, ElC, GMs>>, pub data: Rc<AppData<Ms, Mdl>>, }

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

Methods

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 builder(
    update: UpdateFn<Ms, Mdl, ElC, GMs>,
    view: ViewFn<Mdl, ElC>
) -> AppBuilder<Ms, Mdl, ElC, GMs, UndefinedInitAPI>
[src]

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 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 patch_window_event_handlers(&self)[src]

pub fn add_message_listener<F>(&self, listener: F) where
    F: Fn(&Ms) + 'static, 
[src]

pub fn build(
    init: impl FnOnce(Url, &mut OrdersContainer<Ms, Mdl, ElC, GMs>) -> Init<Mdl> + 'static,
    update: UpdateFn<Ms, Mdl, ElC, GMs>,
    view: ViewFn<Mdl, ElC>
) -> AppBuilder<Ms, Mdl, ElC, GMs, MountPointInitInitAPI<UndefinedMountPoint, InitFn<Ms, Mdl, ElC, GMs>>>
[src]

Deprecated since 0.5.0:

Use builder with AppBuilder::{after_mount, before_mount} instead.

pub fn run(self) -> Self[src]

Deprecated since 0.4.2:

Please use AppBuilder.build_and_start instead

App initialization: Collect its fundamental components, setup, and perform an initial render.

Trait Implementations

impl<Ms, Mdl, ElC: View<Ms>, GMs> Clone for App<Ms, Mdl, ElC, GMs>[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

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]

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.