spierce7
02/28/2021, 1:09 AMprivate val headlinesStateFlow = MutableStateFlow<List<Headline>?>(null)
suspend fun headlines(): Flow<List<Headline>> = flow {
coroutineScope {
async {
headlinesStateFlow.emit(videoService.getHeadlines())
}
emitAll(headlinesStateFlow.filterNotNull())
}
}
Zach Klippenstein (he/him) [MOD]
02/28/2021, 1:36 AMlaunch
not async
spierce7
02/28/2021, 2:03 AMsuspend fun headlines(): Flow<List<Headline>> = flow {
coroutineScope {
headlinesStateFlow.emit(videoService.getHeadlines())
emitAll(headlinesStateFlow.filterNotNull())
}
}
launch
Zach Klippenstein (he/him) [MOD]
02/28/2021, 2:30 AMspierce7
02/28/2021, 2:46 AMasync / await
Zach Klippenstein (he/him) [MOD]
02/28/2021, 3:06 AMasync
without await
it will actually not propagate at all, just drop.Albert Chang
02/28/2021, 3:49 AMspierce7
02/28/2021, 4:00 AM