reagent-project / reagent-template

A Leiningen template for projects using Reagent.
MIT License
394 stars 55 forks source link

Refer dev namespace functions with repl init when using the dev profile #41

Closed alvinfrancis closed 9 years ago

alvinfrancis commented 9 years ago

This is related to #38.

Haven't kept up with the recent changes so I haven't been aware of the switch to preferring lein-figwheel. I recently tried out the latest template and was lost on how to go about starting figwheel and the browser-repl.

My preferred workflow before was to use cider to jack-in from emacs and then starting figwheel from there as well as running the browser-repl with cider. Back then, the dev namespace functions were referred directly by the handler namespace. I have yet to figure out how to connect cider instead to the repl run by lein-figwheel.

Now that the dev functions are separate from the handler, I suggest referring them back instead through :repl-options with :init to save the trouble of having to refer them back in manually:

{:repl-options {:init-ns {{project-ns}}.handler
                :init (use '{{project-ns}}.dev)
                :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl{{{nrepl-middleware}}}]}
yogthos commented 9 years ago

that sounds reasonable

yogthos commented 9 years ago

hmm I just tried it and :init doesn't seem to be doing anything:

rap.handler=> (browser-repl)

clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: browser-repl in this context, compiling:(/private/var/folders/9k/qk6_g3cd5hlb5jgqp6fc8tcm0000gn/T/form-init2473597430966582649.clj:1:1)
             java.lang.RuntimeException: Unable to resolve symbol: browser-repl in this context

if I run use in the repl then it works

rap.handler=> (use 'rap.dev)
nil
rap.handler=> (browser-repl)
<< Started Weasel server on ws://0.0.0.0:9001 >>
Type `:cljs/quit` to stop the ClojureScript REPL
nil

I think it might make sense to set the repl to the dev ns instead of the handler in the first place, since there's really nothing interesting in the handler now.

yogthos commented 9 years ago

I just updated the latest version to use :init-ns {{project-ns}}.dev and it seems to be working with the REPL as expected.

alvinfrancis commented 9 years ago

I'm not familiar with lein's templating so maybe there's a different syntax when using quote. I pretty much just gave the example I had hoping it would be that simple. Manually adding the use call to :init on my project.clj worked for me anyway.

In any case, I'd be quite satisfied too with having the REPL start in the dev namespace. It does make more sense.

yogthos commented 9 years ago

ok great, the latest version should be working as expected then. :)