Created
March 11, 2013 21:27
-
-
Save bendlas/5137917 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 path-cache (atom {})) | |
(defn load-cached [path] | |
(if-let [ret (get @path-cache path)] | |
ret | |
(let [ret (cell nil)] | |
(swap! path-cache assoc path ret) | |
(XhrIo/send path | |
(fn [e] | |
(case (.. e -target getStatus) | |
200 (reset! ret (.. e -target getResponseText)) | |
(log "ERROR" "Request to" path e))) | |
"GET") | |
ret))) | |
;; in this case, html-to-dom is passed a cell object | |
(def overlay | |
(cell (when-let [html (load-cached "/_static/html/backend-overlay.html")] | |
(let [dom (domina/html-to-dom html)] | |
(at js/document | |
["body"] (append dom)) | |
dom)))) | |
;; in this case, html-to-dom is passed a nil from the first transition | |
(def overlay | |
(let [html (load-cached "/_static/html/backend-overlay.html")] | |
(cell (when html | |
(let [dom (domina/html-to-dom html)] | |
(at js/document | |
["body"] (append dom)) | |
dom))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment