router5-plugin-listeners
TypeScript icon, indicating that this package has built-in type declarations

8.0.1 • Public • Published

Router5 listeners plugin

No longer needed!

router.subscribe is now available and as a result listeners plugin is no longer needed.

Usage

import listenersPlugin from 'router5-plugin-listeners'
 
const router = createRouter()
 
router.usePlugin(listenersPlugin())

Types of listeners

Listeners are called with toState and fromState arguments.

Listen to a node change

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.

Listen to any route change

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 removeListener(fn).

Listen to a specific route

addRouteListener(name, fn) will register a listener which will be triggered when the router is navigating to the supplied route name.

Readme

Keywords

Package Sidebar

Install

npm i router5-plugin-listeners

Weekly Downloads

194

Version

8.0.1

License

MIT

Unpacked Size

10.3 kB

Total Files

6

Last publish

Collaborators

  • troch