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(throttleTime): double emission with leading and trailing enabled #4727

Conversation

MatthiasKunnen
Copy link
Contributor

@MatthiasKunnen MatthiasKunnen commented Apr 23, 2019

This PR fixes an issue with throttleTime emitting both leading and trailing values in the same time window.

Double emission problem:

source:   a123b12-c-23d-2-ef---
expected: a---b---c---d---e---f
actual:   a---b1---c2---2-e---f

Closes #2466 and closes #2727.
Follows #2749 and #2864.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8406

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 96.858%

Totals Coverage Status
Change from base Build 8397: 0.002%
Covered Lines: 5796
Relevant Lines: 5984

💛 - Coveralls

@benlesh
Copy link
Member

benlesh commented May 9, 2019

I'm not sure this is the correct behavior. Even if it was, this would be a breaking change for someone.

I'll wait for other core team members to weigh in... @jwo719? @cartant? @kwonoj?

@MatthiasKunnen
Copy link
Contributor Author

I think you've already had a discussion about whether the behavior is intended in #2749. See #2749 (comment).

That PR was closed by the author. Perhaps they didn't have the time.

Test for double emission with leading and trailing enabled.
Also add more tests for leading and trailing enabled.

Double emission problem:
source:   a123b12-c-23d-2-ef---
expected: a---b---c---d---e---f
actual:   a---b1---c2---2-e---f
Fix an issue with throttleTime emitting both leading and trailing values in the same time window.

Double emission problem:
source:   a123b12-c-23d-2-ef---
expected: a---b---c---d---e---f
actual:   a---b1---c2---2-e---f

Closes ReactiveX#2466 and ReactiveX#2727.
Follows ReactiveX#2749 and ReactiveX#2864.

BREAKING CHANGE: throttleTime no longer emits both leading and trailing
values in the same time window.
It was pointed out that the timings could be influenced due to slow user code, this has now been
solved.
@MatthiasKunnen MatthiasKunnen force-pushed the fix-throttle-time-leading-trailing branch from 7dbbb96 to 1a3fe43 Compare July 24, 2019 16:00
@MatthiasKunnen
Copy link
Contributor Author

I've fixed the fact that slow user code could influence timings.

I understand that time is finite and this PR might not be anywhere on the priority list but would a review be possible?

I've also rebased the PR to be up-to-date.

@adolgoff
Copy link

adolgoff commented Mar 6, 2020

PR is definitely fixing unexpected behavior

benlesh added a commit to benlesh/rxjs that referenced this pull request Sep 2, 2020
…least the throttled amount

Works to align the behavior with expectations set by lodash's throttle

- Updates tests
- Ensures trailing throttle will wait to notify and then complete
- Ensures that every time we emit a value a new throttle period starts

fixes ReactiveX#3712
related ReactiveX#4864
fixes ReactiveX#2727
closes ReactiveX#4727
related ReactiveX#4429
benlesh added a commit to benlesh/rxjs that referenced this pull request Sep 3, 2020
…least the throttled amount

Works to align the behavior with expectations set by lodash's throttle

- Updates tests
- Ensures trailing throttle will wait to notify and then complete
- Ensures that every time we emit a value a new throttle period starts

fixes ReactiveX#3712
related ReactiveX#4864
fixes ReactiveX#2727
closes ReactiveX#4727
related ReactiveX#4429
@benlesh benlesh closed this in #5687 Sep 3, 2020
benlesh added a commit that referenced this pull request Sep 3, 2020
…least the throttled amount (#5687)

* fix(throttleTime): ensure the spacing between throttles is always at least the throttled amount

Works to align the behavior with expectations set by lodash's throttle

- Updates tests
- Ensures trailing throttle will wait to notify and then complete
- Ensures that every time we emit a value a new throttle period starts

fixes #3712
related #4864
fixes #2727
closes #4727
related #4429

* chore: Address comments and add comments to the code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants