This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-16
Channels
- # announcements (16)
- # asami (5)
- # aws (2)
- # babashka (4)
- # beginners (22)
- # calva (28)
- # cider (3)
- # clj-kondo (1)
- # cljdoc (13)
- # cljs-dev (16)
- # clojure (3)
- # clojure-australia (1)
- # clojure-europe (25)
- # clojure-gamedev (1)
- # clojure-germany (2)
- # fulcro (34)
- # helix (4)
- # jobs-discuss (16)
- # leiningen (10)
- # malli (20)
- # meander (7)
- # nrepl (35)
- # off-topic (1)
- # portal (13)
- # ring-swagger (3)
- # shadow-cljs (34)
- # tools-deps (7)
- # vim (1)
Use only keywords and predicates in your signature, put your specs in a ns if their own, then preloads to load them in dev, and don't require them anywhere.
That way when you enable gr in dev they will work, and in prod the keywords will still get interned, but spec won't. It's a bit troublesome
Hi, I'm tryna remember what fulcro used to be called. I like the name Fulcro, I was just wondering since I used it a few years ago and the name has changed from when Om.Next was first introduced.
I think it was called "Untangled" https://cljdoc.org/d/fulcrologic/fulcro/2.8.13/doc/readme#_contributors#:~:text=untangled
Oh my gosh thanks I couldn't pull that out of the recesses of brain for the life o' me!
no problem 🙂 I've discovered fulcro (and clojure for that matter) long after that change but it got mentioned here and there in the old docs and in the podcast I think and somehow I remembered it now even though I've never even touched it
Alright here come a bunch of questions:
What does defsc
stand for (in making a react component)?
"define stateful component" https://book.fulcrologic.com/#_the_defsc_macro#:~:text=%22define%20stateful%20component%22
(defmutation bump-number [ignored] <<<<<<<<<<<<<<<
(action [{:keys [state]}]
(swap! state update :ui/number inc)))
(defsc Root [this {:ui/keys [number]}]
{:query [:ui/number]
:initial-state {:ui/number 0}}
(dom/div
(dom/h4 "This is an example.")
(dom/button {:onClick #(comp/transact! this [(bump-number {})])} <<<<<<<<<<<<<<<
"You've clicked this button " number " times.")))
Why the {}
in (bump number {})
? (any empty coll is ok question mark) what's ignored
for?I think it's just a constraint of defmutation
macro that it always takes only one (no more, no less) map argument and in this particular example it's not needed so it's has been named ignored
Clojure convention uses _ for ignored items, but it's not required, you can name them anything.
yeah, I agree (I was even typing that in my answer...) but well, it's just a convention - I don't even know from where you got this snippet
um, ok - I can't speak for author's motivation behind breaking the convention here but maybe it was to prevent overwhelming newcomers with yet another cryptic-and-hard-to-google symbol, but as we could see just now it confused those who know the convention 😉 the middle-ground would be to use _ignored
but that's pretty irrelevant
#3: In practice, do you make a factory for every component?
If I understand this question correctly the factory is for creating ui components, if you don't need a UI for a component you can leave off the factory.
yeah, you need to wrap your stateful ( defsc
) component with (comp/factory
if you want to render it https://book.fulcrologic.com/#_props which is not always the case (e.g. you can use a component just to query/serialize data)
:thinking_face:
so if one wants to make a react component, one needs to use factory every time?

#4: why quote & unquote here https://book.fulcrologic.com/#_mutations
(comp/transact! this `[(add-person {:name ~name})])
add-person is a mutation, if it's not defined in your current namespace you want to send it to the server as data, rather than evaluating the call to add-person in-line, you send it to the mutation to evaluate. If you have add-person required into the current namespace you can drop the quoting and unquoting.
okay interesting, looks like a macro syntax so it puzzles me still
when you import the add-person mutation macro into your current namespace that macro does the quoting and unquoting for you. If you don't import it, you have to do the quoting and unquoting yourself.
Oh. cool. ty
the back tick is used to create a data structure that won't be executed, it's the same as writing:
[(list (symbol "add-person") {:name name})]
the back tick is useful because you don't have to write (list ,,,)
and (symbol ,,,)
. it will also automatically namespace things for you, so if add-person
was required from some other namespace it will create (symbol "some.other.ns" "add-person")
okay is that specific to fulcro or is this a clojure-wide thing? @U4YGF4NGM
I'm pretty sure it's a clojure built-in thing, but just making sure 😅
` and ~