Created
June 13, 2014 21:31
-
-
Save Will-Sommers/9949efd7c3901ccf8b8d to your computer and use it in GitHub Desktop.
Flash of last state text
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
(ns community.location | |
(:require [community.routes :as routes :refer [routes]] | |
[sablono.core :as html :refer-macros [html]])) | |
... | |
... | |
(defn init-location! [app-state] | |
(routes/set-route! app-state) | |
(.addEventListener js/window "popstate" (partial routes/set-route-and-clear! app-state))) | |
(ns community.routes | |
(:require [community.util.routing :as r])) | |
... | |
... | |
(defn set-route! [app] | |
(let [route (routes (-> js/document .-location .-pathname))] | |
(swap! app assoc :route-data route))) | |
(defn set-route-and-clear! [app] | |
(let [previous-route (get-in @app [:route-data :route])] | |
(swap! app assoc previous-route nil) | |
(set-route! app))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment