-
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
operator description might be confusing when not using any seed
#4348
Comments
You are correct and the documentation is wrong. The That also means that the typing is incorrect. Fixing the types has been on my TODO list for some time. |
@cartant I checked it again and documentation for
and that's even when the description for
So comparing I'm just not sure that if I don't set any seed for |
I realised that the behavior is a little different for |
yep, confusing, basically without a seed, scan just passes the event. |
Please prioritize this, this is very confusing and just cost me multiple hours of debugging. I would hate for future developers to get stuck on this same documentation problem, considering it has already been discovered. |
It is also confusing because the docs say
Implying that if no seed is given, |
Documentation Related To Component:
scan
Please check those that apply
Description Of The Issue
The last paragraph in
scan
's docblock says (emphasis is mine):However, the actual
scan
behavior isn't exactly like this:It doesn't apply the
accumulator
function to every item if I don't set any seed. In that case it just passes the first emission through without callingaccumulator
:This will make the following output even when the first item was
"a"
:This is the relevant code:
rxjs/src/internal/operators/scan.ts
Lines 98 to 105 in de9d2e4
Demo: https://stackblitz.com/edit/rxjs6-demo-ynfnan
So even though the sequence started with
"a"
theaccumulator
function was called for the first time for"b"
. Also theindex
passed started at0
for the second item (doesindex
count how many times the function was called or does it count the number of items that went through this operator?).From the last sentence I would guess that the
accumulator
function will be called even for the first value like this order (even though it is a little weird):... while in fact it's called like this:
So maybe I'm just dumb but the description and actual behavior without setting any seed really confused me.
The text was updated successfully, but these errors were encountered: