This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-22
Channels
- # adventofcode (78)
- # announcements (12)
- # babashka (2)
- # beginners (116)
- # calva (20)
- # cider (17)
- # clj-kondo (15)
- # cljs-dev (51)
- # clojure (32)
- # clojure-android (1)
- # clojure-dev (4)
- # clojure-europe (91)
- # clojure-gamedev (1)
- # clojure-italy (2)
- # clojure-nl (1)
- # clojure-spec (12)
- # clojure-taiwan (1)
- # clojure-uk (10)
- # clojurescript (9)
- # conjure (3)
- # cryogen (4)
- # cursive (4)
- # data-science (1)
- # datomic (5)
- # depstar (5)
- # fulcro (39)
- # google-cloud (2)
- # kaocha (2)
- # malli (7)
- # off-topic (3)
- # pathom (3)
- # pedestal (5)
- # re-frame (19)
- # rewrite-clj (54)
- # ring (3)
- # shadow-cljs (12)
- # spacemacs (12)
- # specter (3)
- # tools-deps (63)
reagent (& re-frame) are usually what I go with, and what I mostly see others use for react-based cljs front-ends
If you prefer thin wrappers then helix
. If you prefer to have some nice things at the cost of more abstractions, then reagent
. Can't say anything about uix
- haven't used it.
I almost always use reagent
as well.
How does one explode a vector into args for multi-arity js functions?
I stumbled across https://stackoverflow.com/questions/41190807/in-clojurescript-how-do-i-pass-a-collections-elements-as-arguments-to-a-variab. The discussed example works just fine in my cljs repl using apply
.
But, I can't seem to apply (pun intended) the same logic to some other js functions like Array.push
i.e. (def a (js/Array.)) (apply (.-push a) [1 2])
doesn't work for me and throws #object[TypeError TypeError: Cannot assign to read only property 'length' of function 'function push() { [native code] }']
It's moments like this where I wish cljs just supported the js spread operator i.e. ...
- I don't think it's that far of a cry from the dots and dashes one already has to use for interop.
hmm I'm not sure about that error yet (I can repro I just don't know why) but you can also use .apply
and the prototype method:
(.apply js/Array.prototype.push a (to-array [1 2]))
Ah, thanks! It works : - ) Forgot about the js apply function.