Skip to content

Commit ce02504

Browse files
authored
Merge pull request kibu-australia#30 from AlexWheeler/add-sibiro-example-to-readme
Add Sibiro example to README
2 parents 059ab8c + f594d47 commit ce02504

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You can construct a new instance by calling the `pushy` function.
1818
* `dispatch` fn: gets called when there is a match
1919
* `match` fn: checks if the path matches any routes defined.
2020

21-
Optionally, you can specify an `:identity-fn` which parses and returns the route based on the result of the `match` fn.
21+
Optionally, you can specify an `:identity-fn` which parses and returns the route based on the result of the `match` fn.
2222

2323
### Event listeners
2424

@@ -123,7 +123,29 @@ pushy should work with any routing library:
123123

124124
#_(pushy/set-token! history "/")
125125
#_(pushy/set-token! history "/pages")
126-
126+
```
127+
128+
[Sibiro](https://github.com/aroemers/sibiro)
129+
130+
```clojure
131+
(ns foo.core
132+
(:require [sibiro.core :as sibiro]
133+
[pushy.core :as pushy]))
134+
135+
(def state (atom {}))
136+
137+
(defn set-page! [match]
138+
(assoc state :page match))
139+
140+
(def routes
141+
{[:get "/home" :home]})
142+
143+
(defn match-uri [uri]
144+
(:route-handler (sibiro/match-uri (sibiro/compile-routes routes) uri :get)))
145+
146+
(def history (pushy/pushy set-page! match-uri))
147+
148+
(pushy/start! history)
127149
```
128150

129151
### URL handling

0 commit comments

Comments
 (0)