in flow from kotlin there is a method called state...
# android
a
in flow from kotlin there is a method called stateIn to convert flow to stateFlow . signature of the method asks for Coroutine scope . what exactly i need to pass as scope ?
d
You need to pass a scope that covers the lifetime of the
stateIn
collection. You could pass in a
viewModelScope
.
a
@Dominaezzz thanks but the problem is that the repository classes i have are part of domain module which is a pure java module hence i can not have a reference of viewmodelscope there. In this case i am assuming that the conversion has to be done on the android module side or is there any other option ?
d
You just need a scope.