mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
Fix custom launch builder with unsized context types (#2920)
This commit is contained in:
parent
c11f2ed3cd
commit
6ff7a54706
1 changed files with 27 additions and 1 deletions
|
@ -123,7 +123,33 @@ impl 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.
|
||||
pub fn custom<Cfg, List>(launch_fn: LaunchFn<Cfg, List>) -> LaunchBuilder<Cfg, List> {
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust, no_run
|
||||
/// use dioxus::prelude::*;
|
||||
/// use std::any::Any;
|
||||
///
|
||||
/// #[derive(Default)]
|
||||
/// struct Config;
|
||||
///
|
||||
/// fn my_custom_launcher(root: fn() -> Element, contexts: Vec<Box<dyn Any>>, cfg: Config) {
|
||||
/// println!("launching with root: {:?}", root());
|
||||
/// loop {
|
||||
/// println!("running...");
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn app() -> Element {
|
||||
/// rsx! {
|
||||
/// div { "Hello, world!" }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// LaunchBuilder::custom(my_custom_launcher).launch(app);
|
||||
/// ```
|
||||
pub fn custom<Config, Context: ?Sized>(
|
||||
launch_fn: LaunchFn<Config, Context>,
|
||||
) -> LaunchBuilder<Config, Context> {
|
||||
LaunchBuilder {
|
||||
launch_fn,
|
||||
contexts: vec![],
|
||||
|
|
Loading…
Reference in a new issue