This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-26
Channels
- # beginners (55)
- # bristol-clojurians (4)
- # calva (9)
- # clj-kondo (29)
- # cljsrn (1)
- # clojars (6)
- # clojure (57)
- # clojure-dev (4)
- # clojure-uk (22)
- # clojurescript (52)
- # code-reviews (1)
- # core-async (33)
- # cursive (12)
- # datomic (46)
- # docker (7)
- # figwheel-main (13)
- # fulcro (8)
- # graalvm (3)
- # instaparse (1)
- # kaocha (2)
- # perun (1)
- # portkey (5)
- # re-frame (3)
- # shadow-cljs (46)
- # spacemacs (7)
- # specter (3)
- # vim (1)
- # vscode (3)
Reagent is funded on Clojurists Together and one of the focuses is "Supporting React hooks" . Super excited
@thheller thanks for the heads up. Something lke that should be fine though (apply array (map ...)
or maybe using cljs-beans ?
the issue is that in development react "validates" the elements it gets immediately, walking the entire structure and thus forcing lazy seqs
so the "work" potentially happens at different times. it is known to cause problems if you use any kind of bindings
but I expect it to get much more problematic once concurrent-mode gets enabled. so best to avoid it completely 😛
Thanks for the explanation! Is this issue wouldn't be there, would there be any reason to prefer lazy collections at all? If we exclude mere convenience due to some core functions returning lazy seqs.
IMHO lazy seqs should always be avoided in components. messed up the entire render structure
Yeah, I get that. I was just wondering that maybe under some circumstances a lazy seq would not be realized completely. Maybe some implicit virtualization, dunno. But if that's not the case, then yeah, no point.
Yep, seems like it does that:
(defn expand-seq-dev [s ^clj o]
(into-array (map (fn [val]
(when (and (vector? val)
(nil? (key-from-vec val)))
(set! (.-no-key o) true))
(as-element val))
s)))
> it is a problem when things use macro or function to construct react elements
Not sure I get that. Aren't we using functions to create components all the time? Why would that be a problem?I didn't know about the diff in behavior between dev vs prod. I'll create an issue in helix for that. Thanks!
I’m looking at a re-frame subscription function, and I see something I don’t recognize:
(rf/reg-sub
:page-id
:<- [:route]
(fn [route _]
(-> route :data :name)))
What is the :<-
part for?
I should add, this example project also uses reitit, if that matters.
That's a subscription that a current one depends on
The keyword is a syntax
Oh, ok.
Ok, yes, I’ve seen the chained subscriptions before, a while ago.
I haven't found myself using it much. I've drifted into being extremely explicit with my handler definitions, having shot myself in the foot a bunch by stacking subscriptions into an L3 and using eg. (fn [sub-a sub-b ,,,] ,,,)
instead of (fn [[sub-a sub-b] ,,,] ,,,)
in the second fn.
I assume the benefit is some caching done by re-frame.
I recently read the docs harder and learned the first fn can return a map of subscriptions, then you can use {:keys [,,,]}
later.
every L2 sub (ie. the 2-arity ... supplying only one function) runs every time the app db changes
the L3s downstream only runs when its input subs change, so this is where to hide the more expensive work
it’s basically building memoized computation graph, the benefit is visible with lots of data in the db and expensive data shaping logic
could someone point me at a simple example for running cljc
tests on node with circleCI?
answering my own q, https://github.com/metosin/malli is a good example 🙂
having fun with symbols, in clojure, this works:
(def foo '[user/foo])
=> #'user/foo
(map resolve foo)
=> (#'user/foo)
but in cljs..
cljs.user=> (def foo '[cljs.user/foo])
#'cljs.user/foo
cljs.user=> (map resolve foo)
⬆
WARNING: Can't take value of macro cljs.core/resolve at line 1
Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
(NO_SOURCE_FILE <embedded>:1077:140)
cljs.core.LazySeq.fn (NO_SOURCE_FILE <embedded>:1077:210)
cljs.core.LazySeq.sval (NO_SOURCE_FILE <embedded>:792:151)
cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (NO_SOURCE_FILE <embedded>:798:255)
cljs.core.LazySeq.cljs$core$ISeq$_first$arity$1 (NO_SOURCE_FILE <embedded>:797:366)
Object.cljs.core._first (NO_SOURCE_FILE <embedded>:360:89)
Object.cljs.core.first (NO_SOURCE_FILE <embedded>:504:173)
lumo.pprint.data.LumoPrinter.fipp$visit$IVisitor$visit_seq$arity$2 (NO_SOURCE_FILE <embedded>:6551:104)
Object.fipp.visit.visit_seq (NO_SOURCE_FILE <embedded>:6301:103)
Object.fipp.visit.visit_STAR_ (NO_SOURCE_FILE <embedded>:6310:506)
It is a macro, and macros cannot be passed around as functions to map (nor any other functions that take functions as args.)
Yep, the two platforms diverge, sadly. Resolve on cljs seems to assert its argument is a quoted var too, which makes its use at runtime limited.
I do not know the details, but vars are a place of some significant differences between clj and cljs
so I have heard, anyway.