How to use figwheel with a ring handler, what component?

I would like to use figwheel to reload the interface of the all-clojure project I'm playing with.

The backend serves the REST api and is organized as a group of components from which I create a system in my main function (I use duct to create a handler component). I want to pass state to my handlers using closures, but the only way to configure figwheel to use my handler seems to be to set the ring-handler to enter project.clj , and this requires passing the handler defined in the namespace at the time of lein .

So - is there a way to configure figwheel when I run my component? I'm still very new at Closure, so I probably missed something in sight.

Passing state as parameter to call handler? is a similar question, but the answer there is related to binding the var handler at the top level of the namespace that I am trying to avoid.

+8
clojure ring
source share
2 answers

Figwheel should not be a handler. You can wrap a component that is automatically generated while your server is up and running, scattering this code into a component that depends on your server component so that it starts first. Please note that this is not officially supported. Running lein figwheel from a shell to load a separate JVM is common use.

If you are using the Stuarts component component, I would recommend wrapping the call handler from the server component, rather than through project.clj. Use this project or adapt the code snippet for the berth component.

Please note that figwheel is devtooling, so during the production process you most likely want to serve the compiled js file created with e. Mr. lein-cljsbuild .

+2
source share

James reeves made the fig wheel component here

Duct-Figwheel-Component Component for the Figwheel development tool, designed for use in a duct frame (but can be used in any component-based system).

Installation

Add the following dependency to your project.clj:

[duct/figwheel-component "0.3.3"]

0
source share

All Articles