-
-
Save drcode/0b4a2917b02b2c54c55b to your computer and use it in GitHub Desktop.
This file contains 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 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