-
-
Save milt/0f047f7a796b4fd1c330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def history (Html5History.)) | |
(.setUseFragment history false) | |
(.setPathPrefix history "") | |
(.setEnabled history true) | |
(let [navigation (listen history EventType/NAVIGATE)] | |
(go | |
(while true | |
(let [token (.-token (<! navigation))] | |
(secretary/dispatch! token))))) | |
(events/listen js/document "click" (fn [e] | |
(let [path (.getPath (.parse Uri (.-href (.-target e)))) | |
title (.-title (.-target e))] | |
(when (secretary/any-matches? path) | |
(. history (setToken path title)) | |
(.preventDefault e))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment