Skip to content

Instantly share code, notes, and snippets.

@bonkydog
Last active December 17, 2015 04:09
Show Gist options
  • Select an option

  • Save bonkydog/5548669 to your computer and use it in GitHub Desktop.

Select an option

Save bonkydog/5548669 to your computer and use it in GitHub Desktop.
Make ClojureScript's reader and writer properly namespace records. This is handy for sending records back and forth in EDN.
;; for (defrecord Design [id name]) in namespace tektite.model.design
(cljs.reader/register-tag-parser! "tektite.model.design.Design" tektite.model.design/map->Design)
(extend-protocol IPrintWithWriter
tektite.model.design/Design
(-pr-writer [coll writer opts]
(let [pr-pair (fn [keyval] (pr-sequential-writer writer pr-writer "" " " "" opts keyval))]
(pr-sequential-writer writer pr-pair "#tektite.model.design.Design{" ", " "}" opts coll))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment