Is it ok to read component's arguments in a trait? How can I idiomatically extract them from a state?
I've ended up having few helper functions looking like:
(defn focus-when-selected [{args :rum/args :as state}]
(let [[item _] args]
(when (:selected item)
(.focus (rum/ref-node state ::name-input))))
state)
anduse them like
(rum/defcs edit-c <
{ :did-mount focus-when-selected,
:did-update focus-when-selected }
[state item actions]
A quick improvement idea. Emit warning when a trait function returns nil
hello guys! i'am pretty new to rum 🙂 I tried using cursors and found that view (rum/static, rum/reactive) seems not to be updated when i modify meta of cursor data with vary-meta
. is it ok? or what am i doing wrong?
i am trying to use meta data to store things like loading and error flags, etc.
you shouldn't be using metadata for that.
why not?
it's convinient to put such things in meta other then have tree like {:users {:data [...], :loading? false, has-more? true}}
. Does not it?
If your UI cares about those things, that's a sign to me that it should be data, not metadata. I find it's better to avoid using metadata unless you're doing some crazy macro stuff.
makes sense