-
-
Save danielstockton/e4687846f5e3df140fe192fd5fbe336d 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 compassus-bug.core | |
(:require [compassus.core :as compassus] | |
[goog.dom :as gdom] | |
[om.next :as om :refer-macros [defui]] | |
[om.dom :as dom])) | |
(enable-console-print!) | |
(defmulti read om/dispatch) | |
(defmethod read :foo | |
[{:keys [ast]} _ _] | |
(let [ast' (assoc-in ast [:params :foo] :bar)] | |
{:remote ast'})) | |
(defui Wrapper | |
Object | |
(render [this] | |
(let [{:keys [owner factory props]} (om/get-computed this)] | |
(factory props)))) | |
(defui Child | |
Object | |
(render [this] | |
(dom/a | |
#js {:href "#" | |
:onClick (fn [e] (om/transact! this [:foo]))} | |
"Trigger transact!"))) | |
(def child (om/factory Child)) | |
(defui Index | |
static om/IQuery | |
(query [this] | |
[:foo]) | |
Object | |
(render [this] | |
(dom/div nil | |
(child)))) | |
(def routes | |
{:index Index}) | |
(defn send [remotes cb] | |
(let [query (:remote remotes) | |
ast (om/query->ast query) | |
query (om/ast->query ast)] | |
(println query))) | |
(def reconciler | |
(om/reconciler | |
{:state {} | |
:parser (compassus/parser {:read read | |
:route-dispatch false}) | |
:send send})) | |
(def app | |
(compassus/application | |
{:routes routes | |
:index-route :index | |
:mixins [(compassus/wrap-render Wrapper)] | |
:reconciler reconciler})) | |
(compassus/mount! app (gdom/getElement "app")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment