This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-20
Channels
- # announcements (1)
- # asami (19)
- # beginners (6)
- # biff (1)
- # cljs-dev (3)
- # clojure (27)
- # clojure-europe (7)
- # clojure-gamedev (4)
- # clojure-hungary (47)
- # clojure-nl (5)
- # clojure-norway (29)
- # clojure-uk (5)
- # clojurescript (23)
- # data-science (1)
- # emacs (36)
- # events (3)
- # fulcro (22)
- # graphql (1)
- # gratitude (1)
- # introduce-yourself (3)
- # lsp (5)
- # nbb (7)
- # off-topic (68)
- # other-languages (2)
- # pathom (5)
- # reagent (4)
- # reitit (10)
- # remote-jobs (2)
- # reveal (2)
- # ring (1)
- # shadow-cljs (46)
- # spacemacs (15)
- # tools-deps (4)
Hello. How to create a valid EDN string from arbitrary objects?
I create EDN strings using (with-out-str (pprint something))
. This works fine as long something
contains standard clojure data (maps, vectors, lists, strings, numbers,...). But when there is a nested JavaScript-Object (for example a Promise), then I get invalid EDN. What is the idiomatic way to ensure valid EDN, even if something
is (or contains) JavaScript objects?
It would be ok, when the JavaScript-Object is written as a string, containing the toString()
value. Do I have to walk something
manually and convert the values? Or is there something to help me with the problem?
regular printing has extension mechanisms (eg. IPrintWithWriter
). pprint
does not I think.
I'd recommend validating or not putting non EDN things in there in the first place if your intent is to store and read later
the default is to print "unsupported" things tagged with #object
, is that not enough?
there are also other libs (eg. fipp) that support more customization options than regular pprint
clojurescript web applications use clojure on server (ring) + clojurescript on client(reagent for example) ?
clojurescript and nodejs is not used in general? we have libraries that do something like MERN(mongodb, express, react, nodejs) for clojurescript? i mean back-end clojurescript
there is https://macchiato-framework.github.io/ but i've never used it
i dont say its good idea, i am just curious what people mainly use, and what libraries we mostly have
So I've rebuilt most of our admin system in ClojureScript and so far so good, actually great. Now I'm at the point where I need to integrate some old React components which are written in just plain js + React. The minified .js build containing those is included into the page but I'm not sure how to "interop" with them in Cljs so they appear on the page. If someone could point me in the right direction I would be really grateful.
If they're minified, they probably already include their own version of React. Including them in your CLJS app will be a PITA.
They are and they do contain their own version of React. I was hoping not to have to rewrite them in CLJS at this point because there is quite a bit of code (maybe sometimes later).
Forgot to mention, I do have access to that old code, so if I need to modify something and rebuild again to make it easier to interop with CLJS I can do so.
You can just use them as JS sources, without minifying them before using in CLJS. Similar to how you work with NPM modules.
Unless they require some preprocessing to be built - like some new JS features or using TS. In that case, something like webpack will be required, which can be used with CLJS.
I don't think it is too bad to work around that file providing it's own react. You'd just need something like this in your shadow-cljs.edn file:
:exclusions [cljsjs/react
cljsjs/react-dom
cljsjs/react-dom-server
cljsjs/create-react-class]
and in compiler options:
:js-options
{:resolve {"react" {:target :global
:global "React"}
"react-dom" {:target :global
:global "ReactDOM"}
"create-react-class" {:target :global
:global "createReactClass"}}}