diff --git a/examples/simple/Makefile b/examples/simple/Makefile
deleted file mode 100644
index 74dca32..0000000
--- a/examples/simple/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-
-PROF = dev
-# PROF = dev,test,srcmap
-# PROF = prod,test
-# PROF = prod
-
-CLJSBUILD = client
-
-all: autocompile
-
-run: openbrowser autocompile
-
-openbrowser:
- (sleep 1 && open example.html) &
-
-autocompile:
- rm -rf target
- lein with-profile $(PROF) cljsbuild auto $(CLJSBUILD)
-
-clean:
- lein -o clean
diff --git a/examples/simple/devsrc/devsetup.cljs b/examples/simple/devsrc/devsetup.cljs
new file mode 100644
index 0000000..4025d52
--- /dev/null
+++ b/examples/simple/devsrc/devsetup.cljs
@@ -0,0 +1,6 @@
+(ns devsetup
+ (:require [simpleexample :as example]
+ [figwheel.client :as fw]))
+
+(fw/start {:on-jsload example/run
+ :websocket-url "ws://localhost:3449/figwheel-ws"})
diff --git a/examples/simple/example.html b/examples/simple/example.html
index 074c944..b7dfeab 100644
--- a/examples/simple/example.html
+++ b/examples/simple/example.html
@@ -6,9 +6,17 @@
- This will become an example when the ClojureScript is compiled
-
-
+
diff --git a/examples/simple/project.clj b/examples/simple/project.clj
index 2c67bd0..a88a1cd 100644
--- a/examples/simple/project.clj
+++ b/examples/simple/project.clj
@@ -1,28 +1,32 @@
-
(defproject simple-reagent "0.5.0-alpha"
:dependencies [[org.clojure/clojure "1.6.0"]
- [org.clojure/clojurescript "0.0-2342"]
- [reagent "0.5.0-alpha"]]
- :plugins [[lein-cljsbuild "1.0.3"]]
+ [org.clojure/clojurescript "0.0-2760"]
+ [reagent "0.5.0-alpha2"]
+ [figwheel "0.2.3-SNAPSHOT"]]
+
+ :plugins [[lein-cljsbuild "1.0.4"]
+ [lein-figwheel "0.2.3-SNAPSHOT"]]
+
:hooks [leiningen.cljsbuild]
- :profiles {:prod {:cljsbuild
- {:builds
- {:client {:compiler
- {:optimizations :advanced
- :preamble ^:replace ["reagent/react.min.js"]
- :pretty-print false}}}}}
- :srcmap {:cljsbuild
- {:builds
- {:client {:compiler
- {:source-map "target/client.js.map"
- :source-map-path "client"}}}}}}
- :source-paths ["src"]
- :cljsbuild
- {:builds
- {:client {:source-paths ["src"]
- :compiler
- {:preamble ["reagent/react.js"]
- :output-dir "target/client"
- :output-to "target/client.js"
- :pretty-print true}}}})
+
+ :profiles {:dev {:cljsbuild
+ {:builds {:client {:source-paths ["devsrc"]
+ :compiler
+ {:main devsetup
+ :optimizations :none
+ :source-map true
+ :source-map-timestamp true}}}}}
+
+ :prod {:cljsbuild
+ {:builds {:client {:compiler
+ {:optimizations :advanced
+ :elide-asserts true
+ :pretty-print false}}}}}}
+
+ :figwheel {:repl false}
+
+ :cljsbuild {:builds {:client {:source-paths ["src"]
+ :compiler
+ {:output-dir "target/client"
+ :output-to "target/client.js"}}}})
diff --git a/examples/simple/src/simpleexample.cljs b/examples/simple/src/simpleexample.cljs
index 7d6ac69..ff2d405 100644
--- a/examples/simple/src/simpleexample.cljs
+++ b/examples/simple/src/simpleexample.cljs
@@ -2,18 +2,17 @@
(ns simpleexample
(:require [reagent.core :as reagent :refer [atom]]))
-(def timer (atom (js/Date.)))
-(def time-color (atom "#f34"))
+(defonce timer (atom (js/Date.)))
-(defn update-time [time]
- ;; Update the time every 1/10 second to be accurate...
- (js/setTimeout #(reset! time (js/Date.)) 100))
+(defonce time-color (atom "#f34"))
+
+(defonce time-updater (js/setInterval
+ #(reset! timer (js/Date.)) 1000))
(defn greeting [message]
[:h1 message])
(defn clock []
- (update-time timer)
(let [time-str (-> @timer .toTimeString (clojure.string/split " ") first)]
[:div.example-clock
{:style {:color @time-color}}
@@ -33,5 +32,5 @@
[color-input]])
(defn ^:export run []
- (reagent/render-component (fn [] [simple-example])
- (.-body js/document)))
+ (reagent/render-component [simple-example]
+ (js/document.getElementById "app")))