Struct dioxus_router::prelude::RouterConfig
source · pub struct RouterConfig<R: Routable> { /* private fields */ }
Expand description
Global configuration options for the router.
This implements Default
and follows the builder pattern, so you can use it like this:
#[derive(Clone, Routable)]
enum Route {
#[route("/")]
Index {},
}
let cfg = RouterConfig::default().history(WebHistory::<Route>::default());
Implementations§
source§impl<R> RouterConfig<R>
impl<R> RouterConfig<R>
sourcepub fn on_update(
self,
callback: impl Fn(GenericRouterContext<R>) -> Option<NavigationTarget<R>> + 'static
) -> Self
pub fn on_update( self, callback: impl Fn(GenericRouterContext<R>) -> Option<NavigationTarget<R>> + 'static ) -> Self
A function to be called whenever the routing is updated.
The callback is invoked after the routing is updated, but before components and hooks are updated.
If the callback returns a NavigationTarget
the router will replace the current location
with it. If no navigation failure was triggered, the router will then updated dependent
components and hooks.
The callback is called no more than once per rerouting. It will not be called if a navigation failure occurs.
Defaults to None
.
sourcepub fn history(self, history: impl HistoryProvider<R> + 'static) -> Self
pub fn history(self, history: impl HistoryProvider<R> + 'static) -> Self
The HistoryProvider
the router should use.
Defaults to a different history provider depending on the target platform.
sourcepub fn initial_route(self, route: R) -> Self
pub fn initial_route(self, route: R) -> Self
The initial route the router should use if no history provider is set.
A component to render when an external navigation fails.
Defaults to a router-internal component called FailureExternalNavigation