should edn recognise defrecord?

324 views
Skip to first unread message

Colin Yates

unread,
Feb 24, 2015, 4:40:14 PM2/24/15
to clo...@googlegroups.com
I am sending instances of defrecords from clojurescript via transmit/edn and getting:

2015-Feb-24 19:23:52 +0000 dev-os-mbp.local DEBUG [taoensso.sente] - Bad package: [[:client/message #health.shared.domain.PingCommand{}]] (clojure.lang.ExceptionInfo: No reader function for tag health.shared.domain.PingCommand {:type :reader-exception})

The defrecord is defined using cljx and is definitely there on the server.

Do I need to write a reader function to recognise instances of defrecord - my assumption was that this should just work?

Thanks!

Steve Miner

unread,
Feb 24, 2015, 5:04:55 PM2/24/15
to clo...@googlegroups.com
The edn format does not include records.  The transit README gives an example of how to write a transit handler for a record.  See the section on extensibility.


Before transit existed, there was a little library that I used to encode a Clojure record as a tagged literal (for edn compatibility).  It’s only for the Clojure side at the moment, but I imagine it wouldn’t be hard to port to CLJS.  However, I suggest that you use transit.

Colin Yates

unread,
Feb 25, 2015, 5:43:19 AM2/25/15
to clo...@googlegroups.com
Thanks miner. I see, so I have to treat each record individually. Never mind - I was only using defrecord so I could dispatch on class and protocols. multi-methods and keywords will suffice here.

Thanks again.

Colin Yates

unread,
Feb 27, 2015, 5:44:22 AM2/27/15
to clo...@googlegroups.com
http://www.compoundtheory.com/clojure-edn-walkthrough/ is a nice read around this as well.
Reply all
Reply to author
Forward
0 new messages