-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(scan/reduce): Typings correct for mixed seed/value types #4858
Conversation
benlesh
commented
Jun 12, 2019
- Adds dtslint tests to cover various mixtures of seeds, accumulator results, and value types
- Refactors scan a little bit, as types needed to be updated in the implementation
- Resolves a performance issue where scan was calling next on the destination Subscriber when it had already errored
- Adds dtslint tests to cover various mixtures of seeds, accumulator results, and value types - Refactors scan a little bit, as types needed to be updated in the implementation - Resolves a performance issue where scan was calling next on the destination Subscriber when it had already errored
09876a7
to
7bc49f6
Compare
* The accumulator function called on each source value. | ||
* @param {T|R} [seed] The initial accumulation value. | ||
* @return {Observable<R>} An observable of the accumulated values. | ||
* @param {V|A} [seed] The initial accumulation value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ReactiveX/rxjs/pull/4858/files#diff-bcface33933d00ae116bcf19e16b2b7cR55 specifies seed as S
but it doesn't extends V|A
as comment says - maybe this needs to be S?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh welp maybe above overloading does its job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. These docs need an overhaul, probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. One minor comment/question.
* result of accumulating the values emitted by the source Observable. | ||
* @method reduce | ||
* @owner Observable | ||
*/ | ||
export function reduce<T, R>(accumulator: (acc: T | R, value: T, index?: number) => T | R, seed?: T | R): OperatorFunction<T, T | R> { | ||
export function reduce<V, A>(accumulator: (acc: V | A, value: V, index?: number) => A, seed?: any): OperatorFunction<V, V | A> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does seed
really need to be any
? It seems to be S
in the implementation signature for scan
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the hoops you need to jump through in the implementation if it's S
, I just made it any
. This is the implementation, not the type signature.