Archie
07/26/2020, 12:31 PMViewModel
in Compose
using viewModel()
composable function. I was wondering how to scope these ViewModel
similar to how ViewModel
could be scoped to Activity
/ Fragment
or NavGraph
? Is this possible to do in Compose
?Manuel Wrage
07/26/2020, 12:32 PMViewModelStoreOwner
via ViewModelStoreOwnerAmbient
.andylamax
07/26/2020, 12:45 PMAndrey Kulikov
07/26/2020, 12:54 PMArchie
07/26/2020, 1:29 PMActivity
or Fragment
right?Halil Ozercan
07/26/2020, 2:25 PMviewModel()
composable that connects these worlds but IMO it is far more useful for transitioning to compose, rather than keep using ViewModels as the default state management.
Of course, it depends on a lot of factors and in the end ViewModels can stay around thanks to the introduction of StateFlow
,SharedFlow
. I found that Compose-Hilt-ViewModel
trio play well together in small examples.Archie
07/26/2020, 2:48 PMSharedFlow
already available?Zach Klippenstein (he/him) [MOD]
07/26/2020, 3:32 PMIsNope. https://github.com/Kotlin/kotlinx.coroutines/pull/2069#issuecomment-656645865already available?SharedFlow