ReactiveX / IxJS

The Interactive Extensions for JavaScript
https://reactivex.io/IxJS/
MIT License
1.32k stars 73 forks source link

What happened to the function signature on reduce (and scan)? #311

Closed tvedtorama closed 3 years ago

tvedtorama commented 3 years ago

I tried to upgrade to v4, but all my reduce-related code failed to compile. Turns out the signature for reduce is no longer the same as for array.reduce, with an options-object instead of the two arguments for callback and seed.

This will not compute for me, as it requires huge rewrites. Also, functions requiring an object with a reduce function, will no longer work with IterableX-instances, only arrays.

Why is this change introduced?

trxcllnt commented 3 years ago

@tvedtorama IIRC AsyncIterable's scan and reduce signatures changed to accommodate an optional AbortSignal addition, so I imagine @mattpodwysocki updated Iterable's signatures to maintain symmetry.

That said, it'd be good if Iterable's signature could match both AsyncIterable and the Array built-in's.

tvedtorama commented 3 years ago

Ok,

thank you - that explains the change. I still think this might be a major issue with many upgraders, though. Perhaps it could be possible to support both function signatures?

trxcllnt commented 3 years ago

@tvedtorama Yeah, we should be able to do that easily. I'll open a PR.

trxcllnt commented 3 years ago

@tvedtorama just published ix@4.1.0 with this fix. Thanks!