Joe
10/07/2019, 3:46 PMjava.util.Stream
to a Flow
? would the first generally be the preferred way (or is there another, more idiomatic way?):
result.iterator().asFlow().onCompletion { result.close() }
vs
flow {
result.use {
for (edge in it) {
emit(edge)
}
}
}
gildor
10/07/2019, 3:53 PMelizarov
10/08/2019, 2:24 PMkotlinx-coroutines-jdk8
module).elizarov
10/08/2019, 2:26 PMStream
is single-use, while Flow is multi-use. In the similar case of converting a channel to a flow we’ve picked a different name for conversion method (consumeAsFlow
) to highlight the fact that the resulting Flow
is special — it can be consumed just one. In fact, it must be consumed exactly once.elizarov
10/08/2019, 2:26 PMFiles
streams) and must be used in order to get the underlying resources closed.Joe
10/08/2019, 4:34 PM