https://kotlinlang.org logo
#compose
Title
# compose
t

Travis Griggs

11/22/2023, 7:22 PM
I'm seeking some design advice. I'm learning/working on this composed rewrite of an older franken-app. I'm trying very hard to just use Compose stuff, avoid ViewModels, bindingings, all that stuff. I find that often my app will have a compose tree that looks something like:
Copy code
TopScreen(appStateSortOfThing) {
  ...
  IntermediateGroupingSection(appStateSortOfThing.subChunkOfState) {
    ...
    SmallerGroupingSection(subChunkOfState.smallerChunk) {
      ...
     WeeGroupingSection(smallChunk.weeChunk) {
        ...
        SinglePurposeComposable(weeChunk.singleThing)
}}}}
And then my design evolves, and there's some simple piece of state I need in the leaf node (e.g. a boolean flag) that I need from top level state collection. I don't mind adding the parameter to the SinglePuproseComposable. It represents the evolved design and keeps it isolated from "pass pointer to big model all around". What IS frustrating, is that I have to go add another paremter to each of those intermediate composables, which are often just wrappers around Boxes, Columns, or Rows. Is there a better way? Or is that just the way of it?
plus1 1
👍 1
v

vide

11/22/2023, 8:03 PM
Could you just add it to the smallest common chunk?
Probably to
weeChunk
in this case
2 Views