Fork me on GitHub
#re-frame
<
2017-11-08
>
caleb.macdonaldblack02:11:30

@mikethompson @lovuikeng Are there any examples with deeply nested components?

vbedegi17:11:47

Managing deeply nested, complex components was one of my main goal with re-alm. Each event/message gets routed to the appropriate component's event handler, where the component updates its own (logical) state.

kenny23:11:05

Given that re-frame recomputes all top level subscriptions every time the DB changes, is nesting state recommended over a single flat DB? For example, say I have a login component that stores an email and a password. I can either structure my app DB nested like this:

{:login {:email    ""
         :password ""}}
or flat, like this:
{:login/email    ""
 :login/password ""}
I assume the former is more performant given you'd write your subscriptions like this:
(rf/reg-sub
  :login-state
  (fn [db _]
    (:login db)))

(rf/reg-sub
  :email
  :<- [:login-state]
  (fn [state]
    (:email state)))

(rf/reg-sub
  :password
  :<- [:login-state]
  (fn [state]
    (:password state)))
Do you guys tend to structure your data nested or flat?

mikerod14:11:31

I have had the same thought and still don’t know either.

danielcompton19:11:52

We generally nest things rather than putting everything at the top level. You can still use namespaced keywords though