Last active
December 20, 2015 11:59
-
-
Save aamedina/6127733 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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