andre 2021-04-06T07:22:06.121400Z

andre 2021-04-06T07:22:15.121800Z

hm force update is pretty useful metric

andre 2021-04-06T07:22:43.121900Z

andre 2021-04-06T07:22:48.122300Z

this one also useful

andre 2021-04-06T07:23:16.122900Z

dunno how to do a tree, if you have any ideas would be great

Aeonax 2021-04-06T09:19:43.124200Z

Hi :spock-hand: Is there any good practices about components local state managing? Is it ok to pass ratom into event and then in callback event effect clean it:see_no_evil:

(rf/reg-event-fx :event
 (fn [_ [_ state id]]
  {:mutate [... id [:on-success state] [:on-error state]]}))

(rf/reg-fx ::reset-input #(reset! % nil))

(rf/reg-event-fx :on-success
 (fn [_ [_ state result]]
   :reset-input state}))

(defn component [id]
  (r/with-let [state (r/atom nil)]
    (let [{:keys [loading? value visible?]} @state
          on-submit #(rf/dispatch [:event state id])]
     ... [:input {:value value}] ... [:button {:on-click on-submit}])))
Keep such local state in app-db feels bad - than i need to make sure that it was cleaned. And pass callback into event feels bad, to call it above re-frame dsl.

p-himik 2021-04-06T09:24:31.124400Z

Passing a callback would IMO be better. In that case, there would be a more generic :call effect instead of the :mutate effect. Alternatively, just don't use re-frame at all for such a component. Just treat it as if you were using pure Reagent.

p-himik 2021-04-06T09:25:43.124700Z

The alternative looks especially apt given that :event seems to know a lot about state.

Aeonax 2021-04-06T09:53:14.125100Z

Ah, I see, why it was only event option as :on-success - under the hood of :mutate we use re-graph which uses events as callbacks… And it is a bit intertwined with our app-db for default error-handling…