Skip to content
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

Merged
merged 1 commit into from Aug 26, 2019

Conversation

@benlesh
Copy link
Member

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
@benlesh benlesh force-pushed the benlesh:fix_reduce_types branch from 09876a7 to 7bc49f6 Jun 12, 2019
* 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.

This comment has been minimized.

Copy link
@kwonoj

kwonoj Jun 12, 2019

Member

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?

This comment has been minimized.

Copy link
@kwonoj

kwonoj Jun 12, 2019

Member

uh welp maybe above overloading does its job

This comment has been minimized.

Copy link
@benlesh

benlesh Jun 13, 2019

Author Member

Yeah. These docs need an overhaul, probably.

@kwonoj
kwonoj approved these changes Jun 12, 2019
Copy link
Collaborator

left a comment

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> {

This comment has been minimized.

Copy link
@cartant

cartant Jun 12, 2019

Collaborator

Does seed really need to be any? It seems to be S in the implementation signature for scan.

This comment has been minimized.

Copy link
@benlesh

benlesh Jun 13, 2019

Author Member

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.

@benlesh benlesh merged commit b89ebe5 into ReactiveX:master Aug 26, 2019
5 checks passed
5 checks passed
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: dtslint Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test Your tests passed on CircleCI!
Details
ci/circleci: typescript3 Your tests passed on CircleCI!
Details
@lock lock bot locked as resolved and limited conversation to collaborators Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.