Czar
03/26/2020, 2:57 PMfun serviceSseRequest(sseEmitter: SseEmitter) {
val liveOutput: Channel<String> = doSomethingInBackground()
liveOutput.consumeAsFlow().collect { sseEmitter.emitServerSideEvent(it) }
}
How do I determine that there won't be any more messages in the channel? Maybe there is some other component that I can use instead of the channel here?araqnid
03/26/2020, 2:59 PMclose()
)Czar
03/26/2020, 3:00 PMDennis
03/26/2020, 3:31 PMConceptually, a close is like sending a special close token to the channel. The iteration stops as soon as this close token is received, so there is a guarantee that all previously sent elements before the close are received
bdawg.io
03/26/2020, 5:46 PMclose()
and not cancel()
since that would indeed cause your consumer not to receive all the valuesCzar
03/26/2020, 7:29 PM