This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-12
Channels
- # aleph (5)
- # announcements (1)
- # asami (29)
- # babashka (2)
- # beginners (36)
- # biff (1)
- # cider (6)
- # clj-kondo (29)
- # clj-together (5)
- # clojars (21)
- # clojure (11)
- # clojure-austin (5)
- # clojure-czech (1)
- # clojure-europe (23)
- # clojure-hk (1)
- # clojure-italy (1)
- # clojure-nl (1)
- # clojure-uk (1)
- # clojurescript (38)
- # clojurewerkz (1)
- # cursive (10)
- # data-science (2)
- # datalevin (15)
- # datomic (8)
- # duct (5)
- # emacs (36)
- # events (4)
- # fulcro (7)
- # garden (1)
- # gratitude (1)
- # interop (4)
- # introduce-yourself (1)
- # leiningen (1)
- # missionary (3)
- # music (3)
- # nbb (4)
- # off-topic (21)
- # polylith (6)
- # remote-jobs (5)
- # shadow-cljs (19)
- # specter (4)
- # xtdb (4)
Is there any guide to compiling a cljc library for clj and cljs consumption? I don’t have any npm deps, and I couldn’t find a straightforward guide. any leads would be appreciated
they don't need to be compiled at all. just publish like any clj library, ie. just the files
I did that, but shadow-cljs was throwing an error when I tried to import it.
The required namespace "my-lib.core" is not available, it was required by "my-current-ns.cljs".
I packaged it using`lein uberjar`
since it wasn’t working, I was wondering if I did something wrong.
I can import it in a clojure namespace though.I did publish it to clojars. I figured out the issue, I forgot to add it to the shadow-cljs.edn file. it worked after adding it there. my bad
I am trying to do assoc-in in reframe db and I am getting , What does it mean
router.cljc?rel=1657557358379:204 Uncaught Error: No protocol method IAssociative.-assoc defined for type cljs.core/List:
that you are trying to assoc
something into a list
. so maybe you don't have the actual db? or maybe missed to destructure something?
Thanks for your response @U05224H0W, I am trying something like this https://clojurians.slack.com/archives/C053AK3F9/p1657564702187899 but it is list instead of vector
ok then the answer becomes a bit trickier. do you actually need a list? I mean the easiest would be a vector
Agree it is better, But is there way to do in list? else I would need some more time to change the code
basically you want (update-in db [:a :b :c] update-first-list-element assoc :d "updated")
there are also many libs that tackle exactly these kinds of deeply nested datastructure manipulation problems
manipulating lists is a bit annoying thats why I'm trying to avoid just giving you the code
unless you have an actual very good reason you need a list you should be using a vector
(defn update-nth-list-element [the-list target-idx update-fn & args]
(->> the-list
(map-indexed
(fn [idx item]
(if (not= idx target-idx)
item
(apply update-fn item args))))
(doall)))
(update-nth-list-element (list 1 2 3) 1 inc)
I would add; try to avoid deeply nested structures, if you can. As the above discussion shows, updating them tends to be ugly, and can be error fraught. Perhaps it’s both easy and simple if you use the right library, I don’t know.
how to update values list type to vector here? {:data ({:a "A" :b "B")}
to
{:data [{:a "A" :b "B")}]}
or better have the thing that created that list create a vector instead (likely a lazy-seq?)
But I got the expected output now after changing 🙂 Thanks @U05224H0W for you r help