Skip to content

Commit

Permalink
Provide a url-variable for automatically reloading state
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrove committed Mar 1, 2014
1 parent 0f77487 commit 7627ec0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/omchaya/core.cljs
Expand Up @@ -74,15 +74,17 @@
(async/timeout 30000) (mprint (pr-str @history)))))))

(defn setup! []
(main (. js/document (getElementById "app")) app-state)
(when (:kandan-client? utils/initial-query-map)
(let [api-key (:kandan-api-key utils/initial-query-map)
kandan-client (kandan-api/make-client api-key "http://localhost:3000/remote/faye")
channels (:kandan-channels utils/initial-query-map)
comms (:comms @app-state)]
(put! (:controls comms) [:api-key-updated api-key])
(doseq [channel channels]
(kandan-api/subscribe! kandan-client (str "/channels/" channel) (:api comms))))))
(let [comms (:comms @app-state)]
(main (. js/document (getElementById "app")) app-state)
(when (:restore-state? utils/initial-query-map)
(put! (:controls comms) [:state-restored]))
(when (:kandan-client? utils/initial-query-map)
(let [api-key (:kandan-api-key utils/initial-query-map)
kandan-client (kandan-api/make-client api-key "http://localhost:3000/remote/faye")
channels (:kandan-channels utils/initial-query-map)]
(put! (:controls comms) [:api-key-updated api-key])
(doseq [channel channels]
(kandan-api/subscribe! kandan-client (str "/channels/" channel) (:api comms)))))))

(set! (.-onload js/window) setup!)

Expand Down
3 changes: 2 additions & 1 deletion src/omchaya/utils.cljs
Expand Up @@ -32,7 +32,8 @@
:kandan-api-key (.getParameterValue parsed-uri "kandan-api-key")
:kandan-client? (seq (.getParameterValue parsed-uri "kandan-api-key"))
:log-channels? (or (.getParameterValue parsed-uri "log-channels") false)
:logging-enabled? (= (.getParameterValue parsed-uri "logging-enabled") "true")})
:logging-enabled? (= (.getParameterValue parsed-uri "logging-enabled") "true")
:restore-state? (= (.getParameterValue parsed-uri "restore-state") "true")})

(def logging-enabled?
(:logging-enabled? initial-query-map))
Expand Down

0 comments on commit 7627ec0

Please sign in to comment.