update hook-browser-navigation! to better allow re-initialization
e.g. this is useful when using figwheel where you might have a call to hook-browser-navigation! in your page-load initialization. before, repeated calls to hook-browser-navigation! in this kind of scenario would result in some javascript errors after the first figwheel reload.
This commit is contained in:
parent
9d045ea523
commit
e543af99f3
|
@ -55,13 +55,17 @@
|
||||||
(-> (str (context-url) url)
|
(-> (str (context-url) url)
|
||||||
(string/replace #"(/+)" "/")))
|
(string/replace #"(/+)" "/")))
|
||||||
|
|
||||||
|
(defonce navigate-history (History.))
|
||||||
|
|
||||||
|
(defn- on-navigate-event
|
||||||
|
[event]
|
||||||
|
(secretary/dispatch! (.-token event)))
|
||||||
|
|
||||||
(defn hook-browser-navigation!
|
(defn hook-browser-navigation!
|
||||||
[]
|
[]
|
||||||
(doto (History.)
|
(doto navigate-history
|
||||||
(events/listen
|
(.setEnabled false)
|
||||||
EventType/NAVIGATE
|
(events/listen EventType/NAVIGATE on-navigate-event)
|
||||||
(fn [event]
|
|
||||||
(secretary/dispatch! (.-token event))))
|
|
||||||
(.setEnabled true)))
|
(.setEnabled true)))
|
||||||
|
|
||||||
(defn redirect!
|
(defn redirect!
|
||||||
|
|
Reference in a new issue