is there a way to set up a return map in the initial state that has a to many relationship? I'm thinking something like
(fn [{:keys [name] :as params}]
{:component/name name
:component/list [(comp/get-initial-state Item {:id 1 :name "A"}) (comp/get-initial-state Item {:id 2 :name "B"})]})
oh snap that works. it looks like I just need to apply the ui-item factory to every component in the vector. yay!
people who do the #?(:clj (pc/defmutation {::pc/output ...}) :cljs (m/defmutation ...))
pattern: as you have to (:require-macros [com.wsscode.pathom.connect :as pc])
in cljs for shadow to compile this file, how do you tell clj-kondo/clj-refactor to leave you alone with the com.wsscode.pathom.connect is required but never used
warning?
I don't have the code here but I believe I just have #?(:clj (:require [com.wsscode.pathom.connect :as pc]), ie no require-macros
I use this pattern and just import pc
without a cljc reader macro: https://github.com/lgessler/glam/blob/master/src/main/glam/models/project.cljc#L3
hm, and you have a ::pc
somewhere in that file? I don't think that compiles
yeah but cider still gives me a warning since it's apparently not used if you #?(:clj) the pc/defresolver too. I guess your IDE is ok with it?
I only have ::pc
under :clj
sections, which keeps me from getting an error
from shadow i mean
cider still complains unfortunately. I figured that the kw expansion needs to see the require at read time, same as the reader conditional
but cider seems to be unaware of that. Alas
I just noticed that if I include pathom in the (:require ...)
without a reader conditional, it gets included in the cljs build, adding about 67kb to my shadow-cljs report. but if I just #?(:cljs (:require-macros [com.wsscode.pathom.connect :as pc]))
it isn't there, saving me that bit of space since I don't actually use pathom from cljs
I ran into some surprising behavior with the synchronous comp/transact!!
stuff: #(m/set-value!! this :field value)
will actually clobber any props passed from the parent in the process of setting :field
to value
. to work around this I do
#(comp/transact!! this [(m/set-props ~(assoc props :field value))] {:compressible? true})
but the async version, set-value!
, behaves as expected.
specifically the prop being passed in is used as the ident in the child and it gets set to nil after the first character is typed into an input which calls that onChange
You're changing an id in a mounted component???
Oh, to clarify the ID changing to nil is the behavior I am seeing with the sync transact, not the behavior I want.
If you can put up a minimal repro case of what you’re seeing go wrong I can take a look. You’re claiming that a call to a sync transact is working differently in terms of what ends up in the state atom than an async one. Could be a bug, but I’m not seeing how.
sure. I can repro it with a workspace card forked from fulcro-template: https://github.com/nivekuil/fulcro-template/commit/be807f9588d03f188365f5c835fcb5bc3915f3d3
screenshots show what the state looks like after typing one character into the input, and after two -- it seems the ident gets set to nil upon typing the second "a"
Your form has to have an ID, otherwise the ident has nil for an id. There is nothing wrong with Fulcro here. It’s your code. Add an ID into intiial state for the form.
is this expected to happen only with synchronous transactions? the nil ident does not show up if I use set-value!
instead of set-value!!
, and the existing ident gets modified as expected
adding :form/id :bar
to initial-state doesn't visibly change anything. ident is still [:form/by-id :my-form]
on the first char, then [:form/by-id nil]
on subsequent chars.
well, I don't think my intent is anything weird like that.. but I could be totally mistaken. say you have a Person with a child PersonForm, I want the PersonForm to have an ident [:person-form/id :person/id]
a person form should have the exact same ident as a person. That is the whole point of normalization…changing the table name denormalizes the database…why would you want to do that?
I don't want PersonForm to be always visible (say only if the user can edit Person), so I conditionally mount the PersonForm in Person's render().. is that weird?
if you mean: I want to toggle between an editable and non-editable version of a person, then no, that isn’t weird…but you should not be rendering one within the other, there should be some kind of container above with logic that manages that particular desire by choose which to render. I personally would make that one stateful component for Person that has perhaps two different plain functions that can be used to render the different styles of view. It’s the same data…really, what I do is make it a form and only a form, and play with the css and such to tune how it looks in non-edit mode.
in https://youtu.be/F7QzFpo8pA0 it seems like indexes can be loaded using Fulcro inspect without a resolver for :com.wsscode.pathom.viz.index-explorer/index
how is that working?
ah I reloaded some things and it started working
yeah I use cursive so idk what cider might say