Fix 'request(0)' issue in Scan#1957
Conversation
There was a problem hiding this comment.
What does excessive mean? I'm re-reading this code and the intent of that variable doesn't jump out at me.
There was a problem hiding this comment.
It means we request more than what we should.
If a user requests 1 from scan in onStart, scan need to request 1 to the upstream. However, when scan receives an onNext, it will emit 2 onNext to the downstream: the initial value and accumulator.call(this.value, initialvalue). So the downstream only requests 1, but scan emits 2 values. I use excessive to indicate we are in an excessive state.
So the next time when the downstream requests, I will try to request n-1.
There was a problem hiding this comment.
If a user requests X (X > 1) from scan in onStart, scan can simply request (X-1). In such case, excessive will be false.
There was a problem hiding this comment.
Got it, thanks for the explanation.
|
The logic seems correct to me on a re-read of this code. |
Fix 'request(0)' issue in Scan
#1904 didn't all cases.