i have code like this:
class MyViewModel: ViewModel() {
val myRepository = ExampleRepository()
init {
fetchServerRequest()
}
fun reload() {
fetchServerRequest()
}
private fun fetchServerRequest() {
viewModelScope.launch {
myRepository.fetchServerRequest() //repository returns Flow<String>
.collect {
//handle result
}
}
}
}
Repository returns cold Flow. Is it correct to create new coroutine c every time when i call this method?
Or coroutine will be finished when code in collect will finished?