Skip to content

Figwheel Helper Functionsλ︎

WARNING::Content relates to the classic figwheel versionλ︎

This approach is not require when using figwheel-main, only for older projects that were created using the original version of figwheel

The lein-figwheel template provides several helper functions in dev/user.clj to start Figwheel and a Clojurescript REPL from a Clojure REPL.

In a development environment a Clojure REPL will start in user namespace, so the functions in dev/user.clj are available when you run a Clojure REPl in Spacemacs - SPC m '

(ns user
  (:require
   [figwheel-sidecar.repl-api :as f]))

;; user is a namespace that the Clojure REPL loads if its available

;; Helper functions can also be added for starting and stopping a webserver or other development services


(defn fig-start
  "This starts the figwheel server and watch based auto-compiler."
  []
  (f/start-figwheel!))

(defn fig-stop
  "Stop the figwheel server and watch based auto-compiler."
  []
  (f/stop-figwheel!))

;; com.cemerick/piggieback is added as a :profile :dev :dependency to support an nREPL environment
(defn cljs-repl
  "Launch a ClojureScript REPL that is connected to your build and host environment."
  []
  (f/cljs-repl))

Emacs jack-inλ︎

You can use these Figwheel helper functions with Emacs & Cider (and Spacemacs) by adding the following function in your init.el configuration file (or ~/.spacmacs file in the dotspacemacs/user-config section)

(setq cider-cljs-lein-repl
  "(do
    (user/fig-start)
    (user/cljs-repl))")

When you run the Emacs command clojurescript-jack-in the cider-cljs-lein-repl name is evaluated and the two helper functions are run one after the other.

Atom and ProtoREPLλ︎

See the ClojureScript section on Practicalli, ProtoREPL