Skip to content

Driving a Natal Project with the Emacs CIDER REPL

Chad Stovern edited this page Nov 30, 2015 · 2 revisions

getting started

install natal

npm install -g natal

create an example app

natal init FutureApp --interface om-next

now you can start playing interactively

cd future-app
natal repl

test making a change live

(in-ns 'future-app.core)
(swap! app-state assoc :app/msg "Hello Native World")

rocking some emacs

open emacs and navigate to your project folder

open your project.clj and add the following

:profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.1"]
                                [org.clojure/tools.nrepl "0.2.10"]]
                                :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}

now use cider jack in to launch a repl

connect to your repl and enter the following code

(require
  '[cljs.repl :as repl]
  '[cemerick.piggieback]
  '[ambly.core :as ambly])

(cemerick.piggieback/cljs-repl
  (ambly/repl-env :choose-first-discovered true))

test making a change live in the cider repl

(in-ns 'future-app.core)
(swap! app-state assoc :text "Hello Clojure MKE")

open core.cljs

test making a persistent change to :onPress #(alert in this file and then save and eval the buffer

(touchable-highlight
  {:style {:backgroundColor "#999" :padding 10 :borderRadius 5}
   :onPress #(alert "i'm hackin it live yo")}
  (text {:style {:color "white" :textAlign "center" :fontWeight "bold"}} "press me"))

now press the button to see the change!

result

https://www.dropbox.com/s/n7o8yasr9nnubcr/Screenshot%202015-11-20%2018.35.06.png?dl=0

resources: