You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-22Lines changed: 24 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,13 +32,11 @@ The example found in the repo can be taken for a test-drive [here](http://tylors
32
32
Here is a rundown of the `example` provided with this repo in the folder `/example`. This should allow a better understanding of how to use cyclic-router, for simplicity the styling has been removed here.
33
33
34
34
Starting in the file which has Cycle `run`, router driver needs to be created here along with the other drivers that you might be using.
35
-
Looking at the imports below, [cyclic-history](https://github.com/tylors/cyclic-history) is being used instead of cycle-history.
36
35
37
36
```js
38
37
// main.js
39
38
import {run} from'@cycle/core'
40
39
import {makeDOMDriver} from'cycle-snabbdom'
41
-
import {makeHistoryDriver} from'cyclic-history'
42
40
import {makeRouterDriver} from'cyclic-router'
43
41
import {createHashHistory} from'history'
44
42
@@ -47,12 +45,10 @@ import app from './app' // the function of your app
47
45
run(app, {
48
46
DOM:makeDOMDriver('#app'),
49
47
// Notice how you need to feed in funcs from cyclic-history + history
In this instance we are using `cyclic-history` and `history` to deal with the history API, have a read of the history [docs](https://github.com/rackt/history/tree/master/docs#readme) to find out more information on how that all works.
55
-
56
52
###2.
57
53
58
54
App.js will be used as the place for showing the correct component in reference to current url (what you'd expect from a router!).
@@ -86,15 +82,15 @@ function view(sidebar, children) {
86
82
87
83
functionApp(sources) {
88
84
const {router} = sources // get router out of sources
89
-
const{path$, value$}=router.define(routes) // pass routes into the router
90
-
constsidebar=Sidebar(sources, path$) // pass in sources and path$ into our sidebar
85
+
constmatch$=router.define(routes) // pass routes into the router
86
+
constsidebar=Sidebar(sources, match$.pluck('path')) // pass in sources and path$ into our sidebar
91
87
92
88
// childrenDOM$ takes path$ from `router.define(routes)` above and zips it with values, here is where
93
89
// the components swap in reference to the current url, notice router.path(path) is also passed in
94
90
// for later use in nested routes.
95
91
// This allows components to be nested without ever knowing they are actually nested.
0 commit comments