aioreactive icon indicating copy to clipboard operation
aioreactive copied to clipboard

rx.reduce should yield the initial value for an empty input

Open GregRos opened this issue 10 months ago • 1 comments

Operators on observables should act the same way as similar operators on collections. That includes emulating their behaviors for edge cases.

A reduce operator with an initial value on an empty list will return the initial value, so the same should apply to rx.reduce when applied to an empty observable – one that closes before emitting a value.

This can be achieved by emitting the initial value when the observable completes if no other value has been emitted.

GregRos avatar Feb 27 '25 16:02 GregRos