pub struct LaunchBuilder { /* private fields */ }
Available on crate feature
launch
only.Expand description
A builder for a fullstack app.
Implementations§
Source§impl LaunchBuilder
impl LaunchBuilder
Sourcepub fn new() -> LaunchBuilder
pub fn new() -> LaunchBuilder
Create a new builder for your application. This will create a launch configuration for the current platform based on the features enabled on the dioxus
crate.
Sourcepub fn web() -> LaunchBuilder
Available on crate feature web
only.
pub fn web() -> LaunchBuilder
web
only.Launch your web application.
Sourcepub fn server() -> LaunchBuilder
Available on crate features fullstack
and server
only.
pub fn server() -> LaunchBuilder
fullstack
and server
only.Launch your fullstack axum server.
Sourcepub fn custom(launch_fn: LaunchFn) -> LaunchBuilder
pub fn custom(launch_fn: LaunchFn) -> LaunchBuilder
Provide a custom launch function for your application.
Useful for third party renderers to tap into the launch builder API without having to reimplement it.
§Example
use dioxus::prelude::*;
use std::any::Any;
#[derive(Default)]
struct Config;
fn my_custom_launcher(root: fn() -> Element, contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>, cfg: Vec<Box<dyn Any>>) {
println!("launching with root: {:?}", root());
loop {
println!("running...");
}
}
fn app() -> Element {
rsx! {
div { "Hello, world!" }
}
}
dioxus::LaunchBuilder::custom(my_custom_launcher).launch(app);
Source§impl LaunchBuilder
impl LaunchBuilder
Sourcepub fn with_context_provider(
self,
state: impl Fn() -> Box<dyn Any> + Send + Sync + 'static,
) -> Self
pub fn with_context_provider( self, state: impl Fn() -> Box<dyn Any> + Send + Sync + 'static, ) -> Self
Inject state into the root component’s context that is created on the thread that the app is launched on.
§Example
use dioxus::prelude::*;
use std::any::Any;
#[derive(Default)]
struct MyState {
value: i32,
}
fn app() -> Element {
rsx! {
div { "Hello, world!" }
}
}
dioxus::LaunchBuilder::new()
.with_context_provider(|| Box::new(MyState { value: 42 }))
.launch(app);
Sourcepub fn with_context(
self,
state: impl Any + Clone + Send + Sync + 'static,
) -> Self
pub fn with_context( self, state: impl Any + Clone + Send + Sync + 'static, ) -> Self
Inject state into the root component’s context.
§Example
use dioxus::prelude::*;
use std::any::Any;
#[derive(Clone)]
struct MyState {
value: i32,
}
fn app() -> Element {
rsx! {
div { "Hello, world!" }
}
}
dioxus::LaunchBuilder::new()
.with_context(MyState { value: 42 })
.launch(app);
Source§impl LaunchBuilder
impl LaunchBuilder
Sourcepub fn with_cfg(self, config: impl LaunchConfig) -> Self
pub fn with_cfg(self, config: impl LaunchConfig) -> Self
Provide a platform-specific config to the builder.
§Example
use dioxus::prelude::*;
use dioxus_desktop::Config;
fn app() -> Element {
rsx! {
div { "Hello, world!" }
}
}
dioxus::LaunchBuilder::desktop()
.with_cfg(Config::new().with_window(|w| w.with_title("My App")))
.launch(app);
Auto Trait Implementations§
impl Freeze for LaunchBuilder
impl !RefUnwindSafe for LaunchBuilder
impl !Send for LaunchBuilder
impl !Sync for LaunchBuilder
impl Unpin for LaunchBuilder
impl !UnwindSafe for LaunchBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.