diff --git a/packages/dioxus/src/launch.rs b/packages/dioxus/src/launch.rs index 70a59b867..92a0040c2 100644 --- a/packages/dioxus/src/launch.rs +++ b/packages/dioxus/src/launch.rs @@ -7,55 +7,38 @@ use dioxus_core::VProps; use dioxus_core::{prelude::*, AnyProps}; use dioxus_core::{BoxedContext, CrossPlatformConfig, PlatformBuilder}; +#[cfg(feature = "fullstack")] +macro_rules! impl_launch_builder { + ($($inner:item)*) => { + impl + LaunchBuilder> + where F: ComponentFunction + Send + Sync + 'static + { + $($inner)* + } + }; +} + +#[cfg(not(feature = "fullstack"))] +macro_rules! impl_launch_builder { + ($($inner:item)*) => { + impl + LaunchBuilder> + where F: ComponentFunction + 'static + { + $($inner)* + } + }; +} + /// A builder for a fullstack app. pub struct LaunchBuilder = CurrentPlatform> { cross_platform_config: CrossPlatformConfig

, platform_config: Option<>::Config>, } -#[cfg(feature = "fullstack")] // Fullstack platform builder -impl< - F: ComponentFunction + Send + Sync, - Props: Clone + Send + Sync + 'static, - M: Send + Sync + 'static, - > 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. - pub fn new(component: F) -> Self - where - Props: Default, - { - Self { - cross_platform_config: CrossPlatformConfig::new(VProps::new( - component, - |_, _| true, - Default::default(), - "root", - )), - platform_config: None, - } - } - - /// Create a new builder for your application with some root props. This will create a launch configuration for the current platform based on the features enabled on the `dioxus` crate. - pub fn new_with_props(component: F, props: Props) -> Self { - Self { - cross_platform_config: CrossPlatformConfig::new(VProps::new( - component, - |_, _| true, - props, - "root", - )), - platform_config: None, - } - } -} - -#[cfg(not(feature = "fullstack"))] -// Default platform builder -impl, Props: Clone + 'static, M: 'static> - LaunchBuilder> -{ +impl_launch_builder! { /// 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. pub fn new(component: F) -> Self where