-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Debounce drops last emitted value if complete emitted too soon #257
Comments
I agree this is the right behavior for debounce and we should fix it through a PR. Thanks for reporting @CarlLeth |
xtianjohns
added a commit
to xtianjohns/xstream
that referenced
this issue
Jul 18, 2018
Emit any pending value, then complete, if a source stream completes before a debounce interval closes. Resolve staltz#257.
xtianjohns
added a commit
to xtianjohns/xstream
that referenced
this issue
Jul 18, 2018
Emit any pending value, then complete, if a source stream completes before a debounce interval closes. Resolve staltz#257.
xtianjohns
added a commit
to xtianjohns/xstream
that referenced
this issue
Jul 18, 2018
Clear pending value upon completion. Support falsy emission values such as `false` and 0. Related to staltz#257.
staltz
pushed a commit
that referenced
this issue
Jul 22, 2018
Emit any pending value, then complete, if a source stream completes before a debounce interval closes. Resolve #257.
staltz
pushed a commit
that referenced
this issue
Jul 22, 2018
Clear pending value upon completion. Support falsy emission values such as `false` and 0. Related to #257.
staltz
pushed a commit
that referenced
this issue
Jul 22, 2018
Emit any pending value, then complete, if a source stream completes before a debounce interval closes. Clear pending value upon completion. Support falsy emission values such as `false` and 0. Resolve #257.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given this stream:
const stream = fromDiagram('-1----2-|').debounce(50)
,1 will be emitted, but not 2, because debounce._c calls this.clearInterval() immediately even if a value is waiting to be emitted.
Debounce drops values with the understanding that a fresher value is coming soon after, but that assumption is violated by dropping the last value. If debounce's purpose is to wait until a rapidly-changing value has settled down, I propose that when it receives complete, things have obviously settled down and it should emit any pending value immediately and then complete.
I am using debounce to prevent the problem where xs.combine(a, b, c, d) emits three (potentially erroneous) intermediate values if a, b, c, and d all change from the same initial event. xs.combine(a,b,c,d).debounce(0) should fix the problem nicely, but it doesn't, because of the aforementioned issue. Another option would be to change combine and merge so that synchronous values from multiple of their inputs only trigger one output emission.
The text was updated successfully, but these errors were encountered: