flow

abstract val flow: Flow<T>

A Flow of stream data as it arrives.

Collect this flow to process incoming data incrementally. The flow completes normally when the stream receives all the data without error. If the stream ends abnormally, the flow fails with a StreamException after all buffered chunks have been emitted.

Example:

reader.flow
.catch { e ->
if (e is StreamException) {
handleStreamError(e)
} else {
throw e
}
}
.collect { chunk -> process(chunk) }