Route Events
Last updated
Was this helpful?
Last updated
Was this helpful?
The router emits several events via the , which allows you to listen to router events as they occur. In some situations, you might opt for a router hook, but in other cases, an event might be what you are after.
A good example of where using events might be more appropriate is showing and hiding loaders and other parts of your applications that relate to routing.
The events fired are:
au:router:router-start
au:router:router-stop
au:router:navigation-start
au:router:navigation-end
au:router:navigation-cancel
au:router:navigation-error
To listen to these events, you subscribe to them using the event aggregator like this:
As you might expect, these events are named in an intuitive way depending on the action taking place inside of the router.