Closed jacobemcken closed 2 years ago
The documentation and examples are very sparse so when I found:
(require '[cognitect.transit :as transit]) (def sorted-set-write-handler (transit/write-handler "sorted-set" (fn [o] (vec o))))
Source: https://www.cognitect.com/blog/2015/9/10/extending-transit
I assumed it would also work on the ClojureScript side, but I get:
Uncaught TypeError: self__.tag_fn.call is not a function
Apparently I'm supposed to wrap the string in a function:
(require '[cognitect.transit :as transit]) (def sorted-set-write-handler (transit/write-handler (fn [] "sorted-set") (fn [o] (vec o))))
Is this on purpose or should it be like its Clojure counterpart that wraps non functions in constantly (through fn-or-val)? https://github.com/cognitect/transit-clj/blob/master/src/cognitect/transit.clj#L74
constantly
fn-or-val
The documentation and examples are very sparse so when I found:
Source: https://www.cognitect.com/blog/2015/9/10/extending-transit
I assumed it would also work on the ClojureScript side, but I get:
Apparently I'm supposed to wrap the string in a function:
Is this on purpose or should it be like its Clojure counterpart that wraps non functions in
constantly
(throughfn-or-val
)? https://github.com/cognitect/transit-clj/blob/master/src/cognitect/transit.clj#L74