hey what other stuff might you put in a Destinatio...
# decompose
a
hey what other stuff might you put in a Destination class other than the component it's self? All of mine so far are one to one, Destination -> Component
a
What's the destination class?
a
ya I guess thats just my name for it, so in a Router, my childFactory takes a
Config
and returns one of these "Destination" classes, these classes are what contain the actual
Component
I guess what I'm getting at, is why not have the
childFactory
just return a Component
a
Got it! So there are two reasons for the intermediate
sealed class Child
: 1. CIf your If your navigation may contain different child components, then this approach allows you to switch children exhaustively and safely. 2. You are able to supply additional data, which is not the child's concern and is used at the parent's level (e.g. in the
@Composable fun someParentContent(component: SomeParent) {}
function). Feel free to omit it if you are fine with casting, or if you only have one possible child class.
a
ah the sealed class argument is a good one!
I've been adding a lot of new Components to my project recently and find my self wishing there was some way to slim down the amount of ceremony around it, (Component, Component Interface, Config, Child/Destination, Ui) but no obvious places to me where you could easily cut something.
a
You can avoid the interface, if you are ok with it. There is also an idea of having something as follows:
Copy code
typealias ComponentContent = @Composable (Modifier) -> Unit

interface MyComponent {
    val stack: ChildStack<*, ComponentContent>
}
But they both may impact testability. All that so-called "boilerplate" makes testing with Decompose pretty straightforward.
a
ya, but I do like that part for compose previews and tests ­čśŤ
ya
in general decompose has continued to work really well as the complexity of my project has been growing
a
Thanks for the feedback! Decompose is primarily designed for medium and big projects. I worked on projects with like 2M LOCs and used a similar approach. Worked very well despite the "boilerplate". The most valuable feature is if it compiles then most likely it works.
a
ya thats pretty awesome