Greetings.
We are using Aurelia 1.
We are building a page which acts as a carousel component whose pages are routes in a child router which fetch data from a backend.
To detect when a page has finished loading, we use router events as described in the official documentation.
Is there any way use these events to pass a value back to the event listeners?
For reference, the event parameter has a result property with an output value, but we cannot find a way to populate it. Any value returned by canActivate does not seem to reach this point.
1 Like
We have changed out approach and do not require this anymore.
I am leaving this open in case anyone else needs it.
Regards.
1 Like
Back to this since we are having problems.
We have noticed that if navigation to a route fails due to an error / rejection in canActivate (even when explicitly returning false) the event raised is still RouterEvents.Success, not RouterEvents.Failed or RouterEvents.Canceled. The callback receives as event.result the object {"status":"completed","completed":true} which contains no further information.
Is there a built-in way to detect this kind of failure?
I guess as a safer solution we can ignore router events and use our own events raised on activate / bind, though.
More inconsistent behaviours.
By awaiting router.navigateToRoute we get this result:
- successful
canActivate (truthy return): {"status":"completed","completed":true,"output":undefined} regardless of the value actually returned by canActivate
- failed
canActivate (falsey return): {"status":"completed","completed":true,"output":<return value of canActivate>} and a Success event is triggered with the result described in my previous post which is DIFFERENT from this one.
After further investigations, the spurious successful navigation only happens if the FIRST navigation fails.
Our child router starts off with a default, surely loaded loading page which probably interferes somehow.
This needs futher investigation on our end.