ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Matt Robertson

Android Engineer @ Crossway. Writing on clean arch, clean code, Kotlin, coroutines, & Compose.

Responses (4)

Write a response

I am not sure that these transformations are needed. My question here is why do we need to split the state in different flows. I used this approach with the transformations in LiveData but I ended up that was not a clean approach. Imho, one flow for state is enough

--

Also dispatcher parameter can be cool because as you know you cannot transform livedata in another thread but you can accomplish that helps with flowOn. So user can pass dispatchers like Default in this case it is gonna avoid main thread loads. I think this is the one of most important things and should be used.

--

I think it would make more sense for the initial value (in stateIn) to be a transformation of the upstream's stateFlow value.
Also, if you define the extension on a base viewmodel you don't need to declare the extension on each viewmodel to skip…

--