Poor Man's Figwheel for Ambly

May 30, 2015

Ambly does not currently interoperate with Figwheel (an awesome environment by Bruce Hauman, which automatically loads changed source into your browser execution environment, as well as doing many other cool things.)




In trying to learn more about how Figwheel works, I ended up trying an experiment which relies on the built-in ClojureScript watch service to simulate what Figwheel does, at least to a first-order approximation.

Using the React Native setup (documented at the Ambly Wiki), instead of starting up Ambly normally, you can hook into the the watch capability to ask the REPL to explicitly load a file whenever the watch service results in a build:

(require 'cljs.repl)
(require 'ambly.core)

(let [repl-env (ambly.core/repl-env)] 
  (cljs.repl/repl repl-env 
    :watch "src" 
    :watch-fn 
      (fn [] 
        (cljs.repl/load-file repl-env 
          "src/awesome_project/core.cljs"))))

Here is a demo of it in action:

 




 

Have fun!

Tags: Ambly