Skip to content

Instantly share code, notes, and snippets.

@danielstockton
Created August 3, 2017 09:25
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/f52f87ac604d3523f10100b964b8b957 to your computer and use it in GitHub Desktop.
Save danielstockton/f52f87ac604d3523f10100b964b8b957 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 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))))
(defn send [remotes cb]
(println (:remote remotes)))
(def reconciler
(om/reconciler
{:state {}
:parser (compassus/parser {:read read})
:send send}))
(om/add-root! reconciler
(om/factory Index) (gdom/getElement "app"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment