lein-figwheel

2016-07-26T09:12:25.000105Z

Hi, I have figwheel set up with a :ring-handler my-ns/dev-handler. I am using a library (https://github.com/martintrojer/frinj) that needs a setup function (`(frinj-init!)`) to be run before using any of its functions. I don't want to run the function at the top level of a namespace, so I instead run it in -main (which also starts a jetty server that is used in the production build). The problem now is that the function has not run when I am developing, since figwheel doesn't run -main when I have a ring-handler specified (as far as I know), (frinj-init!) has not been run when I start figwheel and try to develop my application. How do I solve this?

thomas 2016-07-26T12:13:17.000108Z

@curlyfry: could you do a defonce maybe?

thomas 2016-07-26T12:13:28.000109Z

and run the frinj function that way?

2016-07-26T13:06:00.000110Z

@thomas: Thanks for the suggestion, but tried it earlier and it seems to result in an infinite loop when building a jar for production (`compiling my-ns.some-ns` forever)

thomas 2016-07-26T13:39:05.000111Z

😞

thomas 2016-07-26T13:53:41.000112Z

I was playing with boot the other day and that allows you to run an init function in addition to the handler. not sure if FW supports the same though. and it didn’t quite work for me. so YMMV

2016-07-26T14:20:08.000113Z

Ok, I'll keep looking!

2016-07-26T14:22:58.000114Z

Right now I'm thinking about using the following approach: No :ring-handler for figwheel, and I instead start figwheel in one terminal and my server repl in the other. I then run the function that I want to start the server (`-main` or dev-main depending on which ring handler I want). The problem here is that the server is run on a different host which makes it impossible to use the same endpoints as in production (where everything is on the same host). Is there any solution to this?

2016-07-26T14:35:40.000115Z

Hmm, I guess figwheel reloads the code even if I use the port of the jetty server to access my site. I think this works for now, and then maybe I can move to more advanced configs like https://github.com/bhauman/lein-figwheel#scripting-with-component when I want to learn more/my app gets bigger