In an application where the same ValueTree’s are used in many different placed/views/components, how would you recommend using typed “wrappers” of the actual ValueTrees? I watched David Rowland’s great talk about ValueTrees (https://www.youtube.com/watch?v=3IaMjH5lBEY) and am planning to use the “typed wrapper” approach he describes.
For example consider the data model is a list of songs and a volume value and there’s a “CurrentSong” and “SongList” view. I see two ways to deal with multiple components using the same ValueTree
Parse the full model into a typed class that has properties corresponding to the ValueTree’s structure, eg “AppModel” which has a list of Songs and a Volume value. Render the view based on the typed instances, so pass around the typed wrappers instead of value trees. Use a sort of facade pattern on the typed classes that listens to the actual change triggers on the ValueTree.
Render the view from the ValueTree, and let the components themselves create the typed wrappers they need.
Rowland seems to be using 2., but I might very well be mistaken. He also seems to be mixing the view/ui components and typed wrappers into a single entity, there doesn’t seem to be a clear distinction between what is data and what is rendering that data (except of course the data is in the ValueTree).
It seems to me that 1. would be easier to design since there’s a clear distinction between data and view, and the ValueTree would be practically abstracted away from anything but the typed wrappers. There might be downsides to this approach that I’m not aware of.
What approach do you use or recommend?