Hi folks, question: Any real difference for this: ...
# coroutines
g
Hi folks, question: Any real difference for this:
Copy code
override fun encode(
    inputStream: Publisher<out Any>,
    bufferFactory: DataBufferFactory,
    elementType: ResolvableType,
    mimeType: MimeType?,
    hints: MutableMap<String, Any>?
): Flux<DataBuffer> {
   1) return Flux.from(inputStream).map { bufferFactory.wrap(protobufSerializer.encodeToByteArray(elementType)) }
   vs 
   2) return inputStream
        .asFlow()
        .map { bufferFactory.wrap(protobufSerializer.encodeToByteArray(elementType)) }
        .asFlux()
}
Is it worth it to keep the transformation asFlow -> map -> and then return again the Flux ?
j
At first sight I would say go to the point and just define a Flux. But maybe the lambda not being inline in `Flux`'s
map
makes a difference
Also, what is this
InputStream.asFlow()
?
g
the inpustStream.asFlow() uses the ktlx.coroutines extension:
Copy code
public fun <T : Any> Publisher<T>.asFlow(): Flow<T> =
    PublisherAsFlow(this)
The inputStream is a type of Publisher<out Any>. Lets pretend that the map is not inlined in our case, it doesnt make any difference to use the actual implementation of the flow instead of flux? (Since from my understanding the have different implementation details.) If not, if it's possible can u point me to a reference or doc so i can deep dive on it ? Thanks in advance.