-
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
scan doesn't accept undefined as seed value #2047
Labels
bug
Confirmed bug
Comments
jayphelps
added a commit
to jayphelps/rxjs
that referenced
this issue
Oct 18, 2016
…ed value Array#scan supports `undefined` as a valid seed value, so we should too. ```js of(1, 2, 3).scan((acc, x) => acc + ' ' + x); // "undefined 1" // "undefined 1 2" // "undefined 1 2 3" ``` fixes ReactiveX#2047
jayphelps
added a commit
to jayphelps/rxjs
that referenced
this issue
Oct 18, 2016
…ed value Array#scan supports `undefined` as a valid seed value, so we should too. ```js of(1, 2, 3).scan((acc, x) => acc + ' ' + x, undefined); // "undefined 1" // "undefined 1 2" // "undefined 1 2 3" ``` fixes ReactiveX#2047
jayphelps
added a commit
to jayphelps/rxjs
that referenced
this issue
Oct 18, 2016
…ed value Array#scan supports `undefined` as a valid seed value, so we should too. ```js of(1, 2, 3).scan((acc, x) => acc + ' ' + x, undefined); // "undefined 1" // "undefined 1 2" // "undefined 1 2 3" ``` fixes ReactiveX#2047
jayphelps
added a commit
to jayphelps/rxjs
that referenced
this issue
Oct 19, 2016
…ed value Array#reduce supports `undefined` as a valid seed value, so it seems natural that we would too for scan ```js of(1, 2, 3).scan((acc, x) => acc + ' ' + x, undefined); // "undefined 1" // "undefined 1 2" // "undefined 1 2 3" ``` fixes ReactiveX#2047
jayphelps
added a commit
to jayphelps/rxjs
that referenced
this issue
Oct 19, 2016
…ed value Array#reduce supports `undefined` as a valid seed value, so it seems natural that we would too for scan ```js of(1, 2, 3).scan((acc, x) => acc + ' ' + x, undefined); // "undefined 1" // "undefined 1 2" // "undefined 1 2 3" ``` fixes ReactiveX#2047
jayphelps
added a commit
that referenced
this issue
Oct 24, 2016
…itself as a valid seed (#2050) * fix(scan): scan operator now accepts `undefined` itself as a valid seed value Array#reduce supports `undefined` as a valid seed value, so it seems natural that we would too for scan ```js of(1, 2, 3).scan((acc, x) => acc + ' ' + x, undefined); // "undefined 1" // "undefined 1 2" // "undefined 1 2 3" ``` fixes #2047 * fix(reduce): reduce operator now accepts `undefined` itself as a valid seed value Array#reduce supports `undefined` as a valid seed value, so it seems natural that we would too. ```js of(1, 2, 3).reduce((acc, x) => acc + ' ' + x, undefined); // "undefined 1 2 3" ```
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
problem:
scan(reduceFn, undefined)
behaves identically toscan(reduceFn)
proposal:
undefined
is a valid seed value(1) it is not consistent with
Array.prototype.reduce
(2) with certain kinds of reducing functions, this behavior can lead to unexpected behavior
if
initialState
isundefined
, then subject will emitnextState
function instead ofnextState(undefined)
leading to undesired behavior. Using a different value forinitialState
could also result in undesired behavior for example if combined withdistinctUntilChanged
the scan api doc has no mention that
undefined
is not a valid seed valueThe text was updated successfully, but these errors were encountered: