|
@@ -46,8 +46,8 @@ impl RouterService {
|
|
|
let listener = history.listen(move || {
|
|
|
_root_found.set(false);
|
|
|
// checking if the route is valid is cheap, so we do it
|
|
|
- for (slot, _) in _slots.borrow_mut().iter().rev() {
|
|
|
- log::trace!("regenerating slot {:?}", slot);
|
|
|
+ for (slot, root) in _slots.borrow_mut().iter().rev() {
|
|
|
+ log::trace!("regenerating slot {:?} for root '{}'", slot, root);
|
|
|
regen(*slot);
|
|
|
}
|
|
|
});
|
|
@@ -68,20 +68,25 @@ impl RouterService {
|
|
|
}
|
|
|
|
|
|
pub fn push_route(&self, route: &str) {
|
|
|
+ log::trace!("Pushing route: {}", route);
|
|
|
self.history.borrow_mut().push(route);
|
|
|
}
|
|
|
|
|
|
pub fn register_total_route(&self, route: String, scope: ScopeId, fallback: bool) {
|
|
|
+ log::trace!("Registered route '{}' with scope id {:?}", route, scope);
|
|
|
self.slots.borrow_mut().push((scope, route));
|
|
|
}
|
|
|
|
|
|
pub fn should_render(&self, scope: ScopeId) -> bool {
|
|
|
+ log::trace!("Should render scope id {:?}?", scope);
|
|
|
if self.root_found.get() {
|
|
|
+ log::trace!(" no - because root_found is true");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
let location = self.history.borrow().location();
|
|
|
let path = location.path();
|
|
|
+ log::trace!(" current path is '{}'", path);
|
|
|
|
|
|
let roots = self.slots.borrow();
|
|
|
|
|
@@ -90,14 +95,22 @@ impl RouterService {
|
|
|
// fallback logic
|
|
|
match root {
|
|
|
Some((_id, route)) => {
|
|
|
+ log::trace!(
|
|
|
+ " matched given scope id {:?} with route root '{}'",
|
|
|
+ scope,
|
|
|
+ route,
|
|
|
+ );
|
|
|
if route == path {
|
|
|
+ log::trace!(" and it matches the current path '{}'", path);
|
|
|
self.root_found.set(true);
|
|
|
true
|
|
|
} else {
|
|
|
if route == "" {
|
|
|
+ log::trace!(" and the route is the root, so we will use that without a better match");
|
|
|
self.root_found.set(true);
|
|
|
true
|
|
|
} else {
|
|
|
+ log::trace!(" and the route '{}' is not the root nor does it match the current path", route);
|
|
|
false
|
|
|
}
|
|
|
}
|