Skip to content

Commit

Permalink
ensuring cljs.user against reloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Hauman committed Feb 2, 2015
1 parent 56f3f3f commit 1c74bfd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 1 addition & 5 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
# add conditional (utils/dev ) to add assertions to client code
# add copious tests to client

# repl make sure that cljs.user exists before eval

# change example so a simpler app

DONE # make sure cljs_deps is handled correctly
# change example to a simpler app



Expand Down
11 changes: 10 additions & 1 deletion support/src/figwheel/client.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
(catch js/Error e
(result-handler
{:status :exception
:value (pr-str e)
:value (pr-str e)
:stacktrace (if (.hasOwnProperty e "stack")
(truncate-stack-trace (.-stack e))
"No stacktrace available.")}))
Expand All @@ -117,9 +117,18 @@
:value (pr-str e)
:stacktrace "No stacktrace available."}))))

(defn ensure-cljs-user
"The REPL can disconnect and reconnect lets ensure cljs.user exists at least."
[]
(when-not js/cljs
(set! js/cljs #js {}))
(when-not (.-user js/cljs)
(set! (.-user js/cljs) #js {})))

(defn repl-plugin [opts]
(fn [[{:keys [msg-name] :as msg} & _]]
(when (= :repl-eval msg-name)
(ensure-cljs-user)
(eval-javascript** (:code msg)
(fn [res]
(socket/send! {:figwheel-event "callback"
Expand Down

0 comments on commit 1c74bfd

Please sign in to comment.