Skip to content

Instantly share code, notes, and snippets.

@shaunlebron
Last active September 15, 2016 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunlebron/e20649fb7319587f9abf to your computer and use it in GitHub Desktop.
Save shaunlebron/e20649fb7319587f9abf to your computer and use it in GitHub Desktop.
figwheel/reactjs development in ClojureScript (om vs. quiescent)
(ns yourapp.core
(:require [figwheel.client :as fw]
[sablono.core :as html :refer-macros [html]]
[om.core :as om :include-macros true]
[om-tools.core :refer-macros [defcomponent]]
))
(enable-console-print!)
(defonce world (atom {:text "Hello!"}))
(defcomponent Root
[data owner]
(render [_]
(html
[:h1 (:text data)])))
; create a rendering loop, can be called multiple times
(om/root Root world {:target (.getElementById js/document "main-area")})
(fw/watch-and-reload :jsload-callback #(swap! world identity))
(ns yourapp.core
(:require [figwheel.client :as fw]
[sablono.core :as html :refer-macros [html]]
[quiescent :as q :include-macros true]))
(enable-console-print!)
(defonce world (atom {:text "Hello!"}))
(q/defcomponent Root
[data]
(html
[:h1 (:text data)]))
(defn render [data]
(q/render (Root data)
(.getElementById js/document "main-area")))
(add-watch world ::render
(fn [_ _ _ data] (render data)))
(fw/watch-and-reload :jsload-callback #(swap! world identity))
(defonce *whatever* (render @world))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment