Skip to content

Instantly share code, notes, and snippets.

@drcode

drcode/core.cljs Secret

Last active October 28, 2015 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drcode/0b4a2917b02b2c54c55b to your computer and use it in GitHub Desktop.
Save drcode/0b4a2917b02b2c54c55b to your computer and use it in GitHub Desktop.
(ns example.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]))
(def state nil)
(defmulti read om/dispatch)
(defmethod read :foo [_ _ _]
{:value {}})
(defui Child
static om/IQuery
(query [this]
[{:bar [:baz]}])
Object
(render [this]
(dom/div nil "child"
(dom/button #js {:onClick (fn []
(om/set-state! this 55))}
"Press Me"))))
(def child (om/factory Child))
(defui Parent
static om/IQuery
(query [this]
[{:foo (om/get-query Child)}])
Object
(render [this]
(dom/div nil
(child (:foo (om/props this))))))
(def reconciler
(om/reconciler
{:state state
:parser (om/parser {:read read})}))
(om/add-root! reconciler
Parent (gdom/getElement "app"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment