This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-10
Channels
- # announcements (14)
- # beginners (55)
- # calva (4)
- # cider (9)
- # clojure (56)
- # clojure-austin (25)
- # clojure-brasil (1)
- # clojure-dev (29)
- # clojure-europe (44)
- # clojure-mexico (1)
- # clojure-nl (2)
- # clojure-norway (1)
- # clojure-uk (5)
- # clojurescript (15)
- # cursive (9)
- # datomic (5)
- # emacs (30)
- # events (1)
- # graalvm (30)
- # honeysql (17)
- # hyperfiddle (54)
- # introduce-yourself (1)
- # jobs-discuss (6)
- # kaocha (2)
- # leiningen (5)
- # lsp (6)
- # malli (3)
- # missionary (16)
- # off-topic (42)
- # overtone (40)
- # pedestal (2)
- # re-frame (21)
- # shadow-cljs (16)
- # squint (2)
- # tools-deps (14)
Hi, I'm trying parse and read edn (to/from strings) in cljs. I using defrecord for my objects Out of the box it didn't work. I followed advise given by https://coderwall.com/p/3xqr7q/clojurescript-read-string-and-records but getting same error.
(defrecord Test [a b])
(cljs.reader/register-tag-parser! "Test" map->Test)
(def a (->Test 1 2))
(cljs.reader/read-string (pr-str a))
Error
;
; Execution error (ExceptionInfo) at (<cljs repl>:1).
; No reader function for tag dev.user.Test.
On a higher level, I'm trying to use js/localStorage for my app's databut besides that the tag is dev.user.Test
not Test
, so if you adjust that it should be fine
you can also adjust how this is printed in the first place via https://stackoverflow.com/questions/77460039/clojure-clojurescript-how-to-plug-in-custom-print-implementation-for-edn-tag-li/77460102#77460102
@U05224H0W Tried both expressions
(cljs.reader/register-tag-parser! "dev.user.Test" map->Test)
(cljs.reader/register-tag-parser! "dev.user.Test" map->Test)
In both cases error is same
;
; Execution error (ExceptionInfo) at (<cljs repl>:1).
; No reader function for tag dev.user.Test.
@U05224H0W I know a little about transit and my understanding about it was that it helps in communication between apps (eg client - server). This is PWA (offline) so it only needs client side persistent db hence localStorage
Interesting to know about writer customisation. I'll think if it would help me in my data storage design.
it has nothing to do with client - server communication, it also is just the serialization format usable for that
so instead of storing a edn string in localstorage you are storing a transit string, still just a string
@U05224H0W BTW thanks for the Art of Clourescript blog post. I've been using it as inspiration for my app! Pure cljs without any framework
Public Service Announcement: @U05224H0W https://github.com/cognitect/transit-clj says in italics "NOTE: Transit is intended primarily as a wire protocol for transferring data between applications. If storing Transit data durably, readers and writers are expected to use the same version of Transit"