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)
|
||||
(string/replace #"(/+)" "/")))
|
||||
|
||||
(defonce navigate-history (History.))
|
||||
|
||||
(defn- on-navigate-event
|
||||
[event]
|
||||
(secretary/dispatch! (.-token event)))
|
||||
|
||||
(defn hook-browser-navigation!
|
||||
[]
|
||||
(doto (History.)
|
||||
(events/listen
|
||||
EventType/NAVIGATE
|
||||
(fn [event]
|
||||
(secretary/dispatch! (.-token event))))
|
||||
(doto navigate-history
|
||||
(.setEnabled false)
|
||||
(events/listen EventType/NAVIGATE on-navigate-event)
|
||||
(.setEnabled true)))
|
||||
|
||||
(defn redirect!
|
||||
|
|
Reference in a new issue