If ask me shouldnt be used in Compose at all, then no Stable annotation needed. Not used I mean never use in method arguments or inside Composable. Fine using outside with state hoisting etc :)
b
Ben Trengrove [G]
04/14/2023, 7:19 AM
They are most likely not stable as well, so the answer would be no.
We generally recommend you use them just at the top screen level composable and then after that just pass the state from the viewmodel down, not the viewmodel itself
j
Joel Denke
04/14/2023, 2:53 PM
I recommend using them only in Fragment and Activity and pass into composable. Not even root composable make sense imo :) also that will make your @Preview work for root composable as well.
Create ui state from viewmodel and delegate to composable :)
f
Francesc
04/14/2023, 3:33 PM
I recommend using them only in Fragment and Activity and pass into composable
that's not feasible; you may not have fragments in a compose only app, and instantiating all your viewmodels in the activity, if you follow the single activity principle, means they will have all your viewmodels tied to the activity lifecycle instead of the more narrow nav graph lifecycle
s
Stylianos Gakis
04/16/2023, 8:42 PM
Yes, so you gotta do what Ben said
top screen level composable
If you're using navigation this would be in your composable destination which defines its route