[][src]Struct seed::app::builder::Builder

pub struct Builder<Ms: 'static, Mdl: 'static, ElC: View<Ms>, GMs, InitAPIType> { /* fields omitted */ }

Used to create and store initial app configuration, ie items passed by the app creator.

Methods

impl<Ms, Mdl, ElC: View<Ms> + 'static, GMs: 'static, IAM: 'static, MP, II, InitAPIType: InitAPIData<IntoInit = II, MountPoint = MP, IntoAfterMount = IAM>> Builder<Ms, Mdl, ElC, GMs, InitAPIType>[src]

pub fn init<NewII: IntoInit<Ms, Mdl, ElC, GMs>>(
    self,
    new_init: NewII
) -> Builder<Ms, Mdl, ElC, GMs, MountPointInitInitAPI<MP, NewII>>
[src]

Deprecated since 0.5.0:

Used for compatibility with old Init API. Use before_mount and after_mount instead.

pub fn mount<NewMP: MountPoint>(
    self,
    new_mount_point: NewMP
) -> Builder<Ms, Mdl, ElC, GMs, MountPointInitInitAPI<NewMP, II>>
[src]

Deprecated since 0.5.0:

Used for compatibility with old Init API. Use before_mount and after_mount instead.

Choose the element where the application will be mounted. The default one is the element with id = "app".

Examples

// argument is `&str`
mount("another_id")

// argument is `HTMLElement`
// NOTE: Be careful with mounting into body,
// it can cause hard-to-debug bugs when there are other scripts in the body.
mount(seed::body())

// argument is `Element`
mount(seed::body().querySelector("section").unwrap().unwrap())

pub fn before_mount(
    self,
    before_mount: impl FnOnce(Url) -> BeforeMount + 'static
) -> Builder<Ms, Mdl, ElC, GMs, BeforeAfterInitAPI<IAM>>
[src]

Select HTML element where the app will be mounted and how it'll be mounted.

See BeforeMount::mount_point and BeforeMount::mount_type docs for more info.

Example

fn before_mount(_url: Url) -> BeforeMount {
   BeforeMount::new()
       .mount_point("main")
       .mount_type(MountType::Takeover)
}

pub fn after_mount<AM: 'static + IntoAfterMount<Ms, Mdl, ElC, GMs>>(
    self,
    after_mount: AM
) -> Builder<Ms, Mdl, ElC, GMs, BeforeAfterInitAPI<AM>>
[src]

You can create your Model and handle initial URL in this method.

See AfterMount::url_handling for more info about initial URL handling.

Example

fn after_mount(_url: Url, _orders: &mut impl Orders<Msg, GMsg>) -> AfterMount<Model> {
   let model = Model { clicks: 0 };
   AfterMount::new(model).url_handling(UrlHandling::None)
}

pub fn routes(self, routes: RoutesFn<Ms>) -> Self[src]

Registers a function which maps URLs to messages.

When you return None, Seed doesn't call your update function and also doesn't push the new route or prevent page refresh. It's useful if the user clicked on a link and Seed shouldn't intercept it, because it's e.g. a download link.

Example

fn routes(url: Url) -> Option<Msg> {
   Some(Msg::UrlChanged(url))
}

pub fn window_events(self, window_events: WindowEventsFn<Ms, Mdl>) -> Self[src]

Registers a function which decides how window events will be handled.

Example

fn window_events(_model: &Model) -> Vec<Listener<Msg>> {
   vec![keyboard_ev(Ev::KeyDown, Msg::KeyPressed)]
}

pub fn sink(self, sink: SinkFn<Ms, Mdl, ElC, GMs>) -> Self[src]

Registers a sink function.

The sink function is a function which can update the model based on global messages. Consider to use a sink function when a submodule needs to trigger changes in other modules.

Example

fn sink(g_msg: GMsg, _model: &mut Model, _orders: &mut impl Orders<Msg, GMsg>) {
   match g_msg {
       GMsg::SayHello => log!("Hello!"),
   }
}

impl<Ms: 'static, Mdl, ElC: View<Ms> + 'static, GMs: 'static, InitAPIType: InitAPI<Ms, Mdl, ElC, GMs, Builder = Self>> Builder<Ms, Mdl, ElC, GMs, InitAPIType>[src]

pub fn build_and_start(self) -> App<Ms, Mdl, ElC, GMs>[src]

Build, mount and start the app.

impl<Ms: 'static, Mdl, ElC: View<Ms> + 'static, GMs: 'static, MP: MountPoint, II: IntoInit<Ms, Mdl, ElC, GMs>> Builder<Ms, Mdl, ElC, GMs, MountPointInitInitAPI<MP, II>>[src]

pub fn finish(self) -> App<Ms, Mdl, ElC, GMs>[src]

Deprecated since 0.4.2:

Please use .build_and_start instead

Turn this Builder into an App which is ready to run.

Auto Trait Implementations

impl<Ms, Mdl, ElC, GMs, InitAPIType> RefUnwindSafe for Builder<Ms, Mdl, ElC, GMs, InitAPIType> where
    InitAPIType: RefUnwindSafe

impl<Ms, Mdl, ElC, GMs, InitAPIType> Send for Builder<Ms, Mdl, ElC, GMs, InitAPIType> where
    InitAPIType: Send

impl<Ms, Mdl, ElC, GMs, InitAPIType> Sync for Builder<Ms, Mdl, ElC, GMs, InitAPIType> where
    InitAPIType: Sync

impl<Ms, Mdl, ElC, GMs, InitAPIType> Unpin for Builder<Ms, Mdl, ElC, GMs, InitAPIType> where
    InitAPIType: Unpin

impl<Ms, Mdl, ElC, GMs, InitAPIType> UnwindSafe for Builder<Ms, Mdl, ElC, GMs, InitAPIType> where
    InitAPIType: UnwindSafe

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, 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.