dawidhyzy
08/24/2022, 6:58 AM@Composable
usage
class SomeViewModel(
repository: SomeRepository,
) : ViewModel() {
val something: State<String?>
@Composable
get() = repository.something.collectAsState()
}
what could be the implication of including ViewModel
in composition?jannis
08/24/2022, 5:17 PMcollectAsState()
function to then UI.dawidhyzy
08/24/2022, 5:39 PMFlow
needs to be converted to StatFlow
using stateIn
.dawidhyzy
08/24/2022, 5:40 PMViewModel
and vice versaStylianos Gakis
08/24/2022, 6:53 PMdawidhyzy
08/25/2022, 8:56 AMStylianos Gakis
08/25/2022, 9:20 AMdawidhyzy
08/25/2022, 9:35 AMFlow
to StateFlow
?Stylianos Gakis
08/25/2022, 9:06 PMsomething
is a StateFlow itself, since you’re using the collectAsState
without any parameters, is that the case?dawidhyzy
08/26/2022, 5:50 AMStateFlow
mind blown I just checked repository implementation.Stylianos Gakis
08/26/2022, 6:34 AM.something
here and you simply move the collectAsState()
in the UI, it’s pretty much the same thing I guess.