Fork me on GitHub
#fulcro
<
2020-03-05
>
otwieracz07:03:07

Are there any examples of using :dispatch in mutations? I can't find one in fulcro book.

pithyless08:03:13

Just call comp/transact! in ok-action (the env includes app) http://book.fulcrologic.com/#_result_action_for_pessimism

pithyless08:03:38

I think I may have misunderstood. Do you want to transact a different mutation? Or :dispatch to different section of the mutation?

otwieracz09:03:22

I want to transact different mutation. I was always doing just comp/transact! in ok-action, but I thought that there is better way.

Jakub Holý (HolyJak)09:03:26

comp/transact!is what the Book uses in such cases http://book.fulcrologic.com/#_result_action_for_pessimism so I'd stick with that

otwieracz07:03:43

I wanted to dispatch one mutation from another.

otwieracz07:03:50

(in ok-action)

tony.kay19:03:04

3.1.17 on clojars with new Hooks support. Not heavily tested yet, but well-encapsulated so it should not cause any regressions.

moneyparrot 36
moocar20:03:31

Hey folks, I've been really getting into Fulcro recently to build out our company's admin site (and it's awesome!). One of my entities has lots of properties, so I've broken it out into sub components all sharing the same ID (using pathom placeholders). This works fine for reads, but when I add form-state, the form-fields from the sub form don't get picked up. Which makes sense since add-form-config* won't add fields to an entity that already has form config. I managed to hack a workaround by manually associng the subform fields into the form-state config for the top level form, but now I have to call (merge props {:>/sub-form}) in all my fs/checked? calls etc so that it picks up the subform props. Anything I'm missing? Or am I better off not splitting my large form into subforms? I'm beginning to realize that sub forms are best when the subform has a different ident.

(defsc SubForm [_ _]
  {:query [:sub-form/field fs/form-config-join]
   :ident :form/id
   :form-fields #{:sub-form/field}}
  )

(defsc Form [_ _]
  {:query [:form/field {:>/sub-form (comp/get-query SubForm)} fs/form-config-join]
   :ident :form/id
   :form-fields #{:form/field}})

tony.kay22:03:19

@moocar I’ve not tried that specifically, but add :>/sub-form to the parent :form-fields and see what happens

moocar22:03:10

Yeah, I had the same thought. I tried it, and it does pick up the subform, but the subform doesn't contain any fields. I guess because they're sharing the same ident

tony.kay23:03:51

technically that should probably work. I designed form-state before we realized that placeholders were even a thing

tony.kay22:03:05

dirty fields and such might not work right in the diff calculation, since it would find the same ident more than once.

tony.kay22:03:17

that said, it would not be that big of a change to fix it to work I think

tony.kay22:03:48

another approach is to put the query and form fields on the parent, and make the sub-renderers plain components or functions (wihtout queries)

moocar22:03:46

Yeah, I think this will be the "easiest" solution for now. Thanks for the suggestions!

thosmos22:03:51

I think I may have found a small bug in StringBufferedInput … when I have a pristine form, and then make a single change to a SBI input, then reset the form, the SBI input doesn’t reset. This change fixed it for me https://github.com/thosmos/fulcro/commit/58184a87597a424df22168490b1cd8054dd98259 Unfortunately I don’t have time at the moment to make a test, etc

tony.kay23:03:39

thx, added to develop branch

tony.kay23:03:29

in 3.1.18-SNAPSHOT

Jakub Holý (HolyJak)22:03:06

Does it ever make sense to have get-query without wrapping it in a join, ie {..} as in: :query [:my/child (comp/get-query SomeChild)] ? If not, would it be feasible to add a check and a warning for the omission of the brackets?

currentoor22:03:10

no that would not make sense

currentoor22:03:40

comp/defsc already does some compile time checks, i suppose you could add more there

currentoor22:03:55

and shadow-cljs has hooks for displaying them nicely, via exceptions