What’s the best way to scope a VM inside a composa...
# compose
t
What’s the best way to scope a VM inside a composable? I’ve a Pager with x screen and they all use the same VM, but I need a different instance for each screen. Any ideas?
a
CompositionLocalProvider(LocalViewModelStoreOwner provides yourViewModelStoreOwner) { ... }
Also here is the feature request.
t
Yeah, that’s what I’m doing right now but for this to work I need to inject everything in the Activity and pass as parameters to all screens down to the one I need because I’ve to create the vm using the factory instead of using
hiltViewModel()
. So I was wondering if there was already some better way to do it Thanks!