Fork me on GitHub

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


use 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

Alexey Kryazhev16:12:20

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?

Alexey Kryazhev16:12:52

i am trying to use meta data to store things like loading and error flags, etc.

Jan K14:12:50

you shouldn't be using metadata for that.

Alexey Kryazhev16:12:58

it's convinient to put such things in meta other then have tree like {:users {:data [...], :loading? false, has-more? true}}. Does not it?

Jan K16:12:35

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.