I did figure out some strange non expected behavior when resolving the same path several times in sequence.
Using navigo release 4.6.0
Consider following router configuration:
let router = new Navigo(null);
router.on(
'/page1',
function () {
console.log('Navigate to /page1');
}
);
Scenario 1
When resolving route /page1 multiple times in sequence (e.g. 3 times) by either clicking a link <a href='/page1' data-navigo> several times or calling
router.navigate('/page1');
router.navigate('/page1');
router.navigate('/page1');
The route handler is called only once (which is correct behaviour). Thus Navigate to /page1 is only called once after the route changes the first time. In contrast each time the router.navigate() is called/link is clicked a history item is added to browser history by calling history.pushState(). So in that case I would expect history.pushState() is only called once at the first resolve for this route instead of three times.
Scenario 2:
When adjusting route above to add before hook like
before: function (done) {
console.log('Before hook for /page1');
done(false);
}
The browser console outputs Before hook for /page1. Navigo prevents calling the resolve function for this root. Thus Navigate to /page1 is not written to console. Although this should prevent route change a new history item is pushed by calling history.pushState(). The expected behavior would be to stop route handleing wen before handler calls done(false) and thus prevent browser history (and addressbar) to be changed.
I did figure out some strange non expected behavior when resolving the same path several times in sequence.
Using navigo release 4.6.0
Consider following router configuration:
Scenario 1
When resolving route
/page1multiple times in sequence (e.g. 3 times) by either clicking a link<a href='/page1' data-navigo>several times or callingThe route handler is called only once (which is correct behaviour). Thus
Navigate to /page1is only called once after the route changes the first time. In contrast each time therouter.navigate()is called/link is clicked a history item is added to browser history by callinghistory.pushState(). So in that case I would expecthistory.pushState()is only called once at the first resolve for this route instead of three times.Scenario 2:
When adjusting route above to add before hook like
The browser console outputs
Before hook for /page1. Navigo prevents calling the resolve function for this root. ThusNavigate to /page1is not written to console. Although this should prevent route change a new history item is pushed by callinghistory.pushState(). The expected behavior would be to stop route handleing wen before handler callsdone(false)and thus prevent browser history (and addressbar) to be changed.