This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-03
Channels
- # announcements (3)
- # babashka (29)
- # beginners (95)
- # calva (109)
- # cider (16)
- # clj-kondo (6)
- # clj-together (1)
- # cljdoc (2)
- # cljsrn (2)
- # clojure (85)
- # clojure-europe (26)
- # clojure-india (1)
- # clojure-seattle (1)
- # clojure-uk (6)
- # clojurescript (14)
- # conjure (4)
- # cursive (8)
- # datomic (6)
- # emacs (21)
- # events (1)
- # figwheel-main (5)
- # fulcro (11)
- # graalvm (32)
- # graphql (1)
- # holy-lambda (7)
- # humbleui (7)
- # jobs (3)
- # membrane (8)
- # nextjournal (31)
- # off-topic (29)
- # pathom (14)
- # polylith (6)
- # portal (16)
- # practicalli (4)
- # reitit (17)
- # releases (1)
- # remote-jobs (2)
- # ring (4)
- # sci (20)
- # shadow-cljs (24)
- # sql (1)
- # vim (12)
- # xtdb (3)
What is the correct way of incrementing a integer field in the database? (m/set-value! this :foo (inc foo))
does not seem correct when there are multiple of them in the same synchronous block.
What do you mean by multiple of them? All submissions that happen while you hold the ui thread are executed together
Hmm I guess so. What about when the set-value!
call is inside a callback function? The value of foo
might be stale when the set-value!
is called.
@U0CKQ19AQ, Also, I think this is the same reason m/toggle!
exists, right? Because (m/set-value! this :foo (not foo)
is incorrect.
After reading the com.fulcrologic.fulcro.mutations
namespace I think I know why m/set-value!
cannot have a version like react's setState
with updater function -- because in the end the value is set through a mutation set-props
, and mutation arguments cannot be a function.
I guess that's also why there's m/raw-update-value!
which sort of does what I want, but strangely asking for that current-props
which wasn't asked in m/set-value!
.
The reason m/raw-update-value!
has to ask for current-props
is because, unlike the mutation set-props
, it does not have access to the ref
. (Although I don't see why you can't figure out ref
from app
which is typically this
)
Also, m/raw-update-value!
can not be used in a fixed-ident component, since it cannot figure out the ident from the props.