import listenersPlugin from 'router5/plugins/listeners';const router = createRouter().usePlugin(listenersPlugin());
Listeners are called with
addNodeListener(name, fn) will register a listener which will be invoked when the specified route node is the transition node of a route change, i.e. the intersection between deactivated and activated segments.
Listeners registered with
addListener(fn) will be triggered on any route change, including route reloads (toState will be equal to fromState). You can remove a previously added listener by using
addRouteListener(name, fn) will register a listener which will be triggered when the router is navigating to the supplied route name.