Hi. Has anyone tried a custom transit-cljs handler with the latest nbb (1.3.196)? When I try the following script on latest nbb I get a cryptic Cannot write error:thread:
(ns transit-write
(:require [cognitect.transit :as transit]))
(defrecord Point [x y])
;; Modified version of
;; since can't define PointHandler deftype in nbb
(def point-write-handlers
(transit/writer :json
{:handlers
{Point (transit/write-handler (constantly "point")
(fn [v] #js [(.-x v) (.-y v)]))}}))
(transit/write point-write-handlers (Point. 1.5 2.5))
is the script I tried based off a transit-cljs test. Transit https://github.com/cognitect/transit-cljs/blob/3d8a2c49ff1911fd7adfacce2776c3a6b8cc1fce/src/cognitect/transit.cljs#L309-L328 rely on reify
The resulting error I get is:
$ nbb script/transit_write.cljs
----- Error --------------------------------------
Message: Cannot write
Location: /Users/me/code/work/logseq/deps/db/script/transit_write.cljs:14:1
----- Context ------------------------------------
10: {:handlers
11: {Point (transit/write-handler (constantly "point")
12: (fn [v] #js [(.-x v) (.-y v)]))}}))
13:
14: (transit/write point-write-handlers (Point. 1.5 2.5))
^--- Cannot write
----- Stack trace --------------------------------
transit-write - /Users/me/code/work/logseq/deps/db/script/transit_write.cljs:14:1