As far as I remember, a ViewModel is scoped to the...
# compose
z
As far as I remember, a ViewModel is scoped to the first parent Fragment or Activity. In an app with a single Activity and written entirely in compose, wouldn't that result in all VMs scoped to that single Activity? Or probably I misread something πŸ™‚
f
In compose you get ViewModels scoped to the current destination
z
Oh yes, now I remember - they can also be scoped to the current Nav Graph, so if you have sub-nav graphs, they'll be scoped to them.
m
πŸ‘
Yeah, activities, fragments, or destinations of a nav graph
πŸ‘ 1
a
And possibly in the future, scoped to the composable https://issuetracker.google.com/issues/165642391
πŸ‘ 2
z
By the way, nice overview of Jetpack Libs & Compose in your IO talk with Ian -

Using Jetpack libraries in Compose β–Ύ

πŸ‘
m
Thanks πŸ™‚
z
It will be nice to be able to scope a VM to a composable, but if that happens, I think it's going to be after 1.0 πŸ™‚
a
you can do
CompositionLocalProvider(LocalViewModelStoreOwner provides foo) {
same as any other
CompositionLocalProvider
πŸ™ 1
z
Oh nice. I'll get a closer look at the code related to all this. Thanks!
πŸ‘ 1