Fork me on GitHub

Unfortunately no


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.


Oh my gosh thanks I couldn't pull that out of the recesses of brain for the life o' me!

Piotr Roterski15:10:58

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)?

Michael W15:10:32

define stateful component


(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/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?

Piotr Roterski15:10:35

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

Michael W15:10:53

by convention ignored should be _

Michael W15:10:40

Clojure convention uses _ for ignored items, but it's not required, you can name them anything.

Piotr Roterski15:10:49

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

Piotr Roterski15:10:34

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?

Michael W15:10:10

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.

Piotr Roterski15:10:29

yeah, you need to wrap your stateful ( defsc) component with (comp/factory if you want to render it which is not always the case (e.g. you can use a component just to query/serialize data)


so if one wants to make a react component, one needs to use factory every time?

yes 1

#4: why quote & unquote here

(comp/transact! this `[(add-person {:name ~name})])

Michael W16:10:20

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

Michael W17:10:58

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.


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 😅

Jakub Holý (HolyJak)20:10:57

it is clojure thing. It is the same thing you use in macros.