splitEvery
Splits and buffers the Flow of String based on the provided delimiter, emitting each piece as a separate element in the resulting Flow.
This function buffers incoming strings until it encounters the provided delimiter. It then emits each piece as a separate string. If the incoming strings do not contain any delimiter, they are buffered until the delimiter is encountered or the flow is completed.
Return
A new Flow where each element represents a piece split by a delimiter from the original Flow of String.
Example usage:
val flow = flowOf(
"Hel",
"lo,",
" world!",
"\nW",
"elcome to River!"
)
flow
.splitEvery("\n")
.collect(::println) //"Hello, world!", "Welcome to River!"
Content copied to clipboard