mirror of
https://github.com/metosin/reitit.git
synced 2026-02-06 04:03:11 +00:00
Fix FragmentHistory -stop method
This commit is contained in:
parent
b99e25ef4f
commit
d7c025d912
1 changed files with 5 additions and 6 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
;; This version listens for both pop-state and hash-change for
|
;; This version listens for both pop-state and hash-change for
|
||||||
;; compatibility for old browsers not supporting History API.
|
;; compatibility for old browsers not supporting History API.
|
||||||
(defrecord FragmentHistory [on-navigate router listen-key last-fragment]
|
(defrecord FragmentHistory [on-navigate router popstate-listener hashchange-listener last-fragment]
|
||||||
History
|
History
|
||||||
(-init [this]
|
(-init [this]
|
||||||
;; Link clicks and e.g. back button trigger both events, if fragment is same as previous ignore second event.
|
;; Link clicks and e.g. back button trigger both events, if fragment is same as previous ignore second event.
|
||||||
|
|
@ -30,12 +30,11 @@
|
||||||
(-on-navigate this path))))]
|
(-on-navigate this path))))]
|
||||||
(-on-navigate this (-get-path this))
|
(-on-navigate this (-get-path this))
|
||||||
(assoc this
|
(assoc this
|
||||||
:listen-key (gevents/listen js/window
|
:popstate-listener (gevents/listen js/window goog.events.EventType.POPSTATE handler false)
|
||||||
#js [goog.events.EventType.POPSTATE goog.events.EventType.HASHCHANGE]
|
:hashchange-listener (gevents/listen js/window goog.events.EventType.HASHCHANGE handler false))))
|
||||||
handler
|
|
||||||
false))))
|
|
||||||
(-stop [this]
|
(-stop [this]
|
||||||
(gevents/unlistenByKey listen-key))
|
(gevents/unlistenByKey popstate-listener)
|
||||||
|
(gevents/unlistenByKey hashchange-listener))
|
||||||
(-on-navigate [this path]
|
(-on-navigate [this path]
|
||||||
(reset! last-fragment path)
|
(reset! last-fragment path)
|
||||||
(on-navigate (rf/match-by-path router path) this))
|
(on-navigate (rf/match-by-path router path) this))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue