rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
justinlee 2018-01-24T04:40:04.000048Z

@chrisblom You can definitely do that, but the basic problem with that kind of architecture is that changing any of the leaf components often requires you to change props in all the intermediate components. You code ends up feeling really brittle and coupled, and it gets really annoying to change anything. If you want pure components (in the sense of being completely determined on their explicit inputs), a common pattern from the react world is to have a “container” component that is hooked up to the state atom (or a cursor into the atom) and which does any server-side communication or side-effect dispatches if you are using a framework. The container item then just renders a “presentation” component by passing in all the necessary inputs as props.

2018-01-24T09:25:47.000548Z

thanks for the long reply

2018-01-24T09:29:14.000095Z

ok, so if I understand correctly a single reactive top-level component that updates when the app state changes, and passes the current state to all subcomponents can work

2018-01-24T09:36:02.000303Z

but is annoying as when children need to modify properties of their parent, you need to muck around in the global state

2018-01-24T09:57:43.000595Z

the other extreme is to pass cursors around everywhere

2018-01-24T09:59:58.000095Z

and as a middleground between passing mutable state / immutable data everywhere, you can pass cursors to some components where it makes sense, and forward immutable data to the sub components

justinlee 2018-01-24T14:57:40.000023Z

I like to keep state as local as possible and only move it globally when I have to thread it down more than one layer or thread a callback more than one layer. I do that just to keep the global state object smaller. Plenty of people put everything in the global state object though.

justinlee 2018-01-24T14:58:54.000688Z

Whether you pass cursors or pass callbacks is a matter of taste in my opinion.