11# cyclic-router
22cyclic-router is a Router Driver built for Cycle.js
33
4- ** Disclaimer** v2.x.x is for Cycle Diversity!
4+ ** Disclaimer** v2.x.x and v3 are for Cycle Diversity!
55If you are still using @cycle/core please continue to use v1.x.x
66
77## Installation
88
99Using [ npm] ( https://www.npmjs.com/ ) :
1010
11- $ npm install cyclic-router
11+ $ npm install --save cyclic-router
12+
13+ Version 3 requires users to inject the route matcher. We'll use ` switch-path ` for our examples but other
14+ matching libraries could be adapted to be used here:
15+
16+ $ npm install --save switch-path
17+
18+ Note: Version 2 and below use ` switch-path ` for the route matcher always and the above library install is not necesssary/done implicitly.
1219
1320Then with a module bundler like [ browserify] ( http://browserify.org/ ) , use as you would anything else:
1421
@@ -22,7 +29,7 @@ var makeRouterDriver = require('cyclic-router').makeRouterDriver
2229
2330## API
2431
25- For API documentation pleave visit this link [ here] ( http://cyclejs-community.github.io/cyclic-router/docs/ )
32+ For API documentation please visit this link [ here] ( http://cyclejs-community.github.io/cyclic-router/docs/ )
2633
2734## Basic Usage
2835
@@ -32,6 +39,7 @@ import Cycle from '@cycle/xstream-run';
3239import {makeDOMDriver } from ' @cycle/dom' ;
3340import {makeRouterDriver } from ' cyclic-router' ;
3441import {createHistory } from ' history' ;
42+ import switchPath from ' switch-path' ; // Required in v3, not required in v2 or below
3543
3644function main (sources ) {
3745 const match$ = sources .router .define ({
@@ -53,13 +61,14 @@ function main(sources) {
5361
5462Cycle .run (main, {
5563 DOM : makeDOMDriver (' #app' ),
56- router: makeRouterDriver (createHistory ())
64+ router: makeRouterDriver (createHistory (), switchPath) // v3
65+ // router: makeRouterDriver(createHistory()) // <= v2
5766});
5867```
5968
6069### Route Parameters
6170
62- You can pass route parameters to your component by adding them to the component sources.
71+ This behavior changes based on the injected route matcher. In the case of ` switch-path ` , you can pass route parameters to your component by adding them to the component sources.
6372
6473``` js
6574const routes = {
0 commit comments