FunkyMuse
01/25/2021, 10:43 AMprotected val loadingState = BroadcastChannel<Boolean>(Channel.BUFFERED)
val actionReceiver = loadingState.asFlow()
Shalom Halbert
01/25/2021, 2:37 PMSharedFlow
is what you want to useAdam Powell
01/25/2021, 3:42 PMval loadingChannel = Channel<Boolean>(Channel.BUFFERED)
val loadingFlow = loadingChannel.receiveAsFlow()
loadingChannel
and observe using loadingFlow
.FunkyMuse
01/25/2021, 3:42 PMAdam Powell
01/25/2021, 3:43 PMChannel.receiveAsFlow
then no value will be emitted more than once. Are you sure your other code isn't sending to the channel more than once?FunkyMuse
01/25/2021, 3:44 PMAdam Powell
01/25/2021, 3:45 PMFunkyMuse
01/25/2021, 3:47 PMAdam Powell
01/25/2021, 3:57 PMFunkyMuse
01/25/2021, 9:39 PMAdam Powell
01/26/2021, 12:05 AMlaunchWhenResumed
block runs as expected, before the collect
call begins?FunkyMuse
01/26/2021, 10:48 AMval Fragment.viewCoroutineScope get() = viewLifecycleOwner.lifecycle.coroutineScope
Oleksandr Balan
01/26/2021, 1:02 PMcollectSubtitles
is blocking.
I bet you start to collect a Flow
there 🙂FunkyMuse
01/26/2021, 1:02 PM.onEach{}.launchIn(scope)
and put it inside the onResumed block, would it be called in onResume since it's launched in the scope with launchIn?Adam Powell
01/26/2021, 3:05 PMlaunch
inside a single launchWhenResumed
...launchWhenResumed {
launch { collectSubtitles() }
launch { handleDownloadStatus() }
}
FunkyMuse
01/26/2021, 3:07 PMOleksandr Balan
01/26/2021, 3:16 PMscope.launchWhenResumed {
launch { collectSubtitles() }
launch { handleDownloadStatus() }
}
and
scope.launchWhenResumed { collectSubtitles() }
scope.launchWhenResumed { handleDownloadStatus() }
?Adam Powell
01/26/2021, 9:18 PM