Last active
September 15, 2016 09:01
-
-
Save shaunlebron/e20649fb7319587f9abf to your computer and use it in GitHub Desktop.
figwheel/reactjs development in ClojureScript (om vs. quiescent)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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