jean
05/12/2020, 2:32 PMFlowCollector
or anything build through the builder helpers function like flow { }, callbackFlow { }, etc...
.
What I want is to be able to do something like that from my fragment (or activity) but in a “correct” way
private lateinit var collector: FlowCollector<MainFragmentEvent>
private val events = flow<MainFragmentEvent> {
collector = this
}
override onResume() {
lifecycleScope.launch {
collector.emit(MainFragmentEvent.ResumeEvent(requireContext()))
}
}
Can I do that only by using Channel, SendChannel, etc...
and then convert it some how to a Flow
?Zach Klippenstein (he/him) [MOD]
05/12/2020, 3:47 PMEventFlow
, but since that doesn't exist yet you can use BroadcastChannel
, which has an asFlow()
extension method.Nikhil Mule
05/12/2020, 10:17 PMjean
05/13/2020, 5:44 AM