slex-router
v1.20.4
Published
[![CircleCI](https://circleci.com/gh/alexstroukov/slex-libs.svg?style=svg)](https://circleci.com/gh/alexstroukov/slex-libs)
Downloads
32
Readme
Slex Router
$ npm install slex-router
slex-router
is a simple client side router which exposes an rxjs
stream.
Example Usage
import slexRouter from 'slex-router'
const routes = {
'/': {
name: 'home',
...anything
},
'/item/:id': {
name: 'itemDetails',
...anything
},
'/item/:id/child/:childId': {
name: 'itemDetailsDeep',
...anything
},
'/*params': {
name: 'wildcardRoute',
...anything
}
'default': {
name: 'defaultRoute',
...anything
}
}
const router = slexRouter
.createStream(routes)
const subscription = router.subscribe(nextRoute => {
const { route, routeState } = nextRoute
const { name, ...anything } = route
const { id, childId } = routeState
})
subscription.dispose()