[−][src]Struct seed::app::App
Implementations
impl<Ms, Mdl, INodes> App<Ms, Mdl, INodes> where
INodes: IntoNodes<Ms> + 'static,
[src]
INodes: IntoNodes<Ms> + 'static,
We use a struct instead of series of functions, in order to avoid passing repetitive sequences of parameters.
pub fn start(
root_element: impl GetElement,
init: impl FnOnce(Url, &mut OrdersContainer<Ms, Mdl, INodes>) -> Mdl + 'static,
update: impl FnOnce(Ms, &mut Mdl, &mut OrdersContainer<Ms, Mdl, INodes>) + Clone + 'static,
view: impl FnOnce(&Mdl) -> INodes + Clone + 'static
) -> Self
[src]
root_element: impl GetElement,
init: impl FnOnce(Url, &mut OrdersContainer<Ms, Mdl, INodes>) -> Mdl + 'static,
update: impl FnOnce(Ms, &mut Mdl, &mut OrdersContainer<Ms, Mdl, INodes>) + Clone + 'static,
view: impl FnOnce(&Mdl) -> INodes + Clone + 'static
) -> Self
Create, mount and start the App
. It's the standard way to create a Seed app.
NOTE: It tries to hydrate the root element content => you can use it also for prerendered website.
Example
fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model { orders .subscribe(Msg::UrlChanged) .notify(subs::UrlChanged(url)); Model { clicks: 0, } } fn update(msg: Msg, model: &mut Model, _orders: &mut impl Orders<Msg>) { match msg { Msg::Clicked => model.clicks += 1, } } fn view(model: &Model) -> impl IntoNodes<Msg> { button![ format!("Clicked: {}", model.clicks), ev(Ev::Click, |_| Msg::Clicked), ] } #[wasm_bindgen(start)] pub fn start() { // Mount to the root element with id "app". // You can pass also `web_sys::Element` or `web_sys::HtmlElement` as a root element. // It's NOT recommended to mount into body or into elements which contain scripts. App::start("app", init, update, view); }
Panics
Panics if the root element cannot be found.
pub fn update(&self, message: Ms)
[src]
Invoke your update
function with provided message.
pub fn update_with_option(&self, message: Option<Ms>)
[src]
Invoke your update
function with provided message.
If the message is None
, then your update
won't be invoked,
but rerender will be still scheduled.
pub fn notify<SubMs: 'static + Any + Clone>(&self, message: SubMs)
[src]
pub fn notify_with_notification(&self, notification: Notification)
[src]
pub fn mailbox(&self) -> Mailbox<Ms>
[src]
Trait Implementations
impl<Ms, Mdl, INodes> Clone for App<Ms, Mdl, INodes> where
INodes: IntoNodes<Ms>,
[src]
INodes: IntoNodes<Ms>,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Ms, Mdl, INodes> Debug for App<Ms, Mdl, INodes> where
Ms: 'static,
Mdl: 'static,
INodes: IntoNodes<Ms>,
[src]
Ms: 'static,
Mdl: 'static,
INodes: IntoNodes<Ms>,
Auto Trait Implementations
impl<Ms, Mdl, INodes> !RefUnwindSafe for App<Ms, Mdl, INodes>
impl<Ms, Mdl, INodes> !Send for App<Ms, Mdl, INodes>
impl<Ms, Mdl, INodes> !Sync for App<Ms, Mdl, INodes>
impl<Ms, Mdl, INodes> Unpin for App<Ms, Mdl, INodes>
impl<Ms, Mdl, INodes> !UnwindSafe for App<Ms, Mdl, INodes>
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,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,