Fix the router and stub out a number of crates to get compiling
This commit is contained in:
226 files changed
+1057
-1482
No files matched your search
@@ -16,34 +16,31 @@ impl<R> Clone for OutletContext<R> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn use_outlet_context<R: 'static>(cx: &ScopeState) -> &OutletContext<R> {
|
||||
let outlet_context = cx.use_hook(|| {
|
||||
cx.consume_context().unwrap_or(OutletContext::<R> {
|
||||
pub(crate) fn use_outlet_context<R: 'static>() -> OutletContext<R> {
|
||||
use_hook(|| {
|
||||
consume_context().unwrap_or(OutletContext::<R> {
|
||||
current_level: 1,
|
||||
_marker: std::marker::PhantomData,
|
||||
})
|
||||
});
|
||||
outlet_context
|
||||
})
|
||||
}
|
||||
|
||||
impl<R> OutletContext<R> {
|
||||
pub(crate) fn render(cx: Scope) -> Element<'_>
|
||||
pub(crate) fn render() -> Element
|
||||
where
|
||||
R: Routable + Clone,
|
||||
{
|
||||
let router = use_router_internal(cx)
|
||||
.as_ref()
|
||||
.expect("Outlet must be inside of a router");
|
||||
let outlet: &OutletContext<R> = use_outlet_context(cx);
|
||||
let router = use_router_internal().expect("Outlet must be inside of a router");
|
||||
let outlet: OutletContext<R> = use_outlet_context();
|
||||
let current_level = outlet.current_level;
|
||||
cx.provide_context({
|
||||
provide_context({
|
||||
OutletContext::<R> {
|
||||
current_level: current_level + 1,
|
||||
_marker: std::marker::PhantomData,
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(error) = router.render_error(cx) {
|
||||
if let Some(error) = router.render_error() {
|
||||
if current_level == 0 {
|
||||
return Some(error);
|
||||
} else {
|
||||
@@ -51,6 +48,6 @@ impl<R> OutletContext<R> {
|
||||
}
|
||||
}
|
||||
|
||||
router.current::<R>().render(cx, current_level)
|
||||
router.current::<R>().render(current_level)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::{
|
||||
any::Any,
|
||||
collections::HashSet,
|
||||
@@ -42,7 +43,7 @@ pub struct RouterContext {
|
||||
subscriber_update: Arc<dyn Fn(ScopeId)>,
|
||||
routing_callback: Option<AnyRoutingCallback>,
|
||||
|
||||
failure_external_navigation: fn(Scope) -> Element,
|
||||
failure_external_navigation: fn() -> Element,
|
||||
|
||||
any_route_to_string: fn(&dyn Any) -> String,
|
||||
}
|
||||
@@ -287,12 +288,12 @@ impl RouterContext {
|
||||
self.update_subscribers();
|
||||
}
|
||||
|
||||
pub(crate) fn render_error<'a>(&self, cx: Scope<'a>) -> Element<'a> {
|
||||
pub(crate) fn render_error(&self) -> Element {
|
||||
self.state
|
||||
.borrow()
|
||||
.unresolved_error
|
||||
.as_ref()
|
||||
.and_then(|_| (self.failure_external_navigation)(cx))
|
||||
.and_then(|_| (self.failure_external_navigation)())
|
||||
}
|
||||
|
||||
fn change_route(&self) -> Option<ExternalNavigationFailure> {
|
||||
|
||||
Reference in new issue
Block a user