Skip to content

Instantly share code, notes, and snippets.

@danielstockton
Last active August 3, 2017 09:07
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 danielstockton/e4687846f5e3df140fe192fd5fbe336d to your computer and use it in GitHub Desktop.
Save danielstockton/e4687846f5e3df140fe192fd5fbe336d to your computer and use it in GitHub Desktop.
(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