New to Reactive Programming here.
Inside a Multi transform, I need to accumulate bytes for few iterations, examining incoming bytes and when I encounter a particular byte pattern, I publish the entire accumulated byteArray for further consumption.
Seems like a simple requirement but I'm stuck.
Pseudo Kotlin code:
val array = listOf<ByteArray>(....)
Multi.createFrom().items(array)
.onItem.transform { oneByteArray: ByteArray ->
if (oneByteArray.indexOf(0x0d) == -1) {
// somehow accumulate oneByteArray somewhere (1)
// do not publish anything downstream (2)
} else {
// publish accumulated byteArrays as one large byteArray
}
}
I'm stuck on (1) and (2). What are the mechanics of temporarily stopping the publication downstream (while I'm looking for a specific byte) ?