id | mainCompare | lesson | compare | title | learnAbout | learnBackAbout | layout | class | image | preview_image | preview_image_alt | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
max |
reduce |
26 |
|
How the RxJS "max" operator works under the hood (scan, reduce) |
count |
reduce |
default |
post |
max/scanreducemax.gif |
max/content_preview.jpg |
scan, reduce, max |
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?
In RxJS, ❚ min
and ❚ max
accept on optional comparer function as an argument.
For example: