3 ms·
This is a very good breakdown of a useful pattern. I think they dismiss declarative approaches with too broad of strokes, but there is always room for frank dis
by shoover 12y ago
This is a very good breakdown of a useful pattern. I think they dismiss declarative approaches with too broad of strokes, but there is always room for frank discussion of lighter, straightforward approaches that get the job done. This overlaps with Codecademy's messaging architecture with React presented by Bonnie Eisenman at React Conf [1], except Codecademy took it a step further and dynamically generated the mediator linkage using mixins pertaining to the views in play for a given screen.
We pretty much write desktop apps in this style but run into problems in some complex situations, so I am parsing this for clues to where we may be letting problems sneak in. The rule that programmatic UI updates never raise events may be such a clue, indicating some views are doing too much direct interaction with both local state and subviews.
Question: are there rules to apply to this architecture to help with data modularity up and across the view tree? A lot of the work around React right now has to do with creating techniques to avoid passing state across levels that don't directly depend on it. For example, communicating an event two levels up without involving the intervening parent or communicating across subviews that don't share a common parent. As I read the OP, you have to pass the event all the way up and the state all the way down, coupling the dataflow and triggering rerenders pretty much all along the path.
[1] https://www.youtube.com/watch?v=ZM6wXoFTY3o&feature=youtu.be https://www.youtube.com/watch?v=ZM6wXoFTY3o&feature=youtu.be