Skip to content

Instantly share code, notes, and snippets.

@aamedina
Last active December 20, 2015 11:59
Show Gist options
  • Save aamedina/6127733 to your computer and use it in GitHub Desktop.
Save aamedina/6127733 to your computer and use it in GitHub Desktop.
(defmacro pub!
[coll port-key val]
`(cljs.core.async/put! (~port-key (:channels (meta ~coll))) ~val))
(defmacro sub!
[[coll port-key] & body]
`(go! ;; this is just an infinite (go) loop, waiting for stuff to be pushed onto the channel
(let [~coll (cljs.core.async/<! (~port-key (:channels (meta ~coll))))]
~@body)))
;; how i'd like things to work :)
(defview datagrid-body [coll]
(sub! [coll :sort] (dommy/replace! (sel1 :tbody) (datagrid-rows coll)))
[:div.table-scrollable
[:table.table.table-bordered.table-condensed
(datagrid-columns coll)
(datagrid-rows coll)]])
.. elsewhere, trigged by click perhaps...
(defn td [coll attr]
(pub! coll :sort (sort-by attr > coll)))
So my question is: How do you think I should go about preserving metadata on the coll, like the list of channels, remote url, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment