Cycle Route
A simple router factory that takes a static map of route => label and returns a function that maps a path to a route object.
It was created to be used with cycle-pushstate-driver
but is a generic URL mapper that can be as a helper in any routing engine.
Install
npm install cycle-route
API
makeRouter(routes)
Takes as input a map from route definition to route name and returns a router function. cycle-route
uses routington
so it accepts all route definitions that routington
accepts and adds a *
route to define the default route.
Format of route object
path: '/' // this is the input path name: 'home' // this is the value from the routes map params: {} // this are the matched params
Usage
Basics:
const router =
Cycle.js use case:
const router = { const Route = Path const homeRequests = const fooRequests = const barRequests = const localLinkClick$ = DOM const navigate$ = DOM const vtree$ = RxObservable return DOM: vtree$ Path: navigate$ PreventDefault: localLinkClick$ ;}