max

reduce

accepts 1 input stream, an accumulator, a seed (optional)

  • The seed will be used as an initial accumulation acc
  • When the input stream emits a value v:
    • v and the latest acc are given to the accumulator
    • the returned value will be used as the next acc
  • When the input stream completes, the output stream emits the last acc and completes

returns a new stream of accumulated values

max

accepts

  • (coming soon)

returns

Published on Monday, 12 Mar. 2018
Revised on Monday, 8 Oct. 2018

This is how a ❚ max operator would operate with an input stream:

  • When the input stream completes, the output stream:
    • emits the largest value emitted on the input stream
    • and immediately completes

Some reactive stream libraries (eg. RxJS) provide this ❚ max operator, while others don’t. How would you code max yourself?

Comparer function

In RxJS, ❚ min and ❚ max accept on optional comparer function as an argument.

For example:

See also


Pipeable operators - Build your own with RxJS!

Cédric Soulas Follow Hire me

Freelance Developer Advocate. Motion graphics with code. JavaScript and Elm. cedricsoulas.com

Subscribe to reactive.how newsletter

Join the Newsletter

Learn Reactive Programming and stay up-to-date:

Receive my latest news, product updates and programming visualizations. You can unsubscribe at any time.

Highlights

@CedricSoulas

Making an illustrated book!

The Illustrated Book of RxJS

Learn more →