Skip to content

Instantly share code, notes, and snippets.

@qbg
Created February 27, 2014 18:09
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 qbg/9255539 to your computer and use it in GitHub Desktop.
Save qbg/9255539 to your computer and use it in GitHub Desktop.
Breaking React change
(ns om-tut.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]))
(enable-console-print!)
(def app-state (atom {:text "Works", :data {:text "Doesn't"}}))
(defn liker
[data owner]
(reify
om/IInitState
(init-state [_] {:count 0})
om/IRenderState
(render-state [_ {:keys [count]}]
(dom/p nil
(dom/button
#js {:onClick #(do
(println "Incrementing from " count)
(om/set-state! owner :count (inc count)))}
"Like")
count))))
(defn like-data
[root owner]
(om/build liker (:data root)))
; Works
(om/root
liker
app-state
{:target (. js/document (getElementById "app0"))})
;;; Doesn't
(om/root
like-data
app-state
{:target (. js/document (getElementById "app1"))})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment