reactor-kotlin-extensions / reactor.kotlin.extra.math / reactor.core.publisher.Flux / sum

sum

fun <T : Number> Flux<T>.sum(): Mono<Long>

Extension to compute the Long sum of all values emitted by a Flux of Number and return it as a Mono of Long.

Note that summing decimal numbers with this method loses precision, see sumDouble.

Author
Simon Baslé

Since
3.1.1

fun <T> Flux<T>.sum(mapper: (T) -> Number): Mono<Long>

Extension to map arbitrary values in a Flux to Numbers and return the sum of these Numbers as a Mono of Long.

Float and Double are rounded to Long by MathFlux, using Java standard conversions.

Parameters

mapper - a lambda converting values to Number

Author
Simon Baslé

Since
3.1.1