I saw the same thing and also wondered that. Because CFlow starts "collecting" from the original flow on behalf of the UI, and passes back the "Job" in form of a Closable so that he UI can cancel the collecting coroutine when it doesn't want to get more values.
But where do you clean up stuff in a UIViewController? viewDidUnload doesn't exist anymore...
clhols
12/09/2019, 9:42 PM
I am trying to use the same concept from CFlow in a ViewModel that implements CoroutineScope. A function to observe a dataFlow: Flow<Data> would then be:
fun observeData(callback: (List<Data>) -> Unit) : Cancelable {