Developing a wee "learning app" with duct/component/figwheel, using emacs 
and cider, and I've hit a snag.

I want the sexy auto-reloading of code that figwheel provides, but as the 
good Weavejester says 
in https://github.com/weavejester/duct-figwheel-component/issues/1, that's 
not a port of the duct figwheel-component component.  So I followed the 
suggestion of that thread and tried hawk.

Only... okay, I added "start-watch" into dev/user.clj:

    (defn start-watch []
      (hawk/watch! [{:watcher :polling
                     :paths ["src" "dev"]
                     :filter (fn [ctx e] (is-srcfile (:file e)))
                     :handler (fn [ctx e]
                                (println "File " (.getName (:file e)) 
"Changed")
                                (reloaded.repl/reset))}]))

This actually sorta works; it watches the directories and tells me if 
anything changes (is-srcfile just checks for .clj or .cljs extension so 
emacs temp files don't set off a cascade of resets).

    user> (start-watch)
    {:thread #object[java.lang.Thread 0x467d27f1 
"Thread[Thread-67,5,main]"], :watcher 
#object[sun.nio.fs.WindowsWatchService 0x5957d994 
"sun.nio.fs.WindowsWatchService@5957d994"]}
    user> 

So a watcher is set up.  If I change user.clj and save it... well, nothing 
happens in my *cider-repl* frame, but in my *nrepl-server* frame, I get

    File  user.clj Changed
    :reloading (user)
     java.lang.IllegalStateException: Can't change/establish root binding 
of: *ns* with set
at clojure.lang.Var.set(Var.java:221)
at clojure.lang.RT$1.invoke(RT.java:241)
at clojure.tools.namespace.repl$do_refresh.invokeStatic(repl.clj:95)
at clojure.tools.namespace.repl$do_refresh.invoke(repl.clj:82)
at clojure.tools.namespace.repl$refresh.invokeStatic(repl.clj:145)
at clojure.tools.namespace.repl$refresh.doInvoke(repl.clj:128)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at reloaded.repl$reset.invokeStatic(repl.clj:53)
at reloaded.repl$reset.invoke(repl.clj:51)
at user$start_watch$fn__45776.invoke(user.clj:67)
        ...


So hawk is obviously watching my source tree and calling my handler 
function, but when reloaded.repl/reset is called, something is blowing up. 
 I can call (reset) directly in the *cider-repl* frame and it works fine.

But I'm obviously doing something horribly wrong, and it seems like it 
should be quite easy.  What am I missing here?  Should this be done 
somewhere besides user.clj?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to