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): ensure the spacing between throttles is always at least the throttled amount #5687

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Sep 2, 2020

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

Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but the behaviour surprised me a little. See comment below.

const e1subs = ' ^------------------!';
const t = time(' ----| ');
// ----|---|----|---|---|
const expected = '-----y--------x---x---|';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question/nitpick: Should this really delay/throttle the completion of the source? This isn't the behaviour that I would have expected. Whatever the case, this test's description doesn't seem to describe what it's actually testing, IMO. If this is how it's supposed to behave, I think the description should explicitly state that complete notifications that are received whilst throttling will be delayed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... yeah, I think if it has to trailing value we should probably complete it.. I'll make that change and merge.

…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 force-pushed the Issue-3712-throttleTime-ensure-proper-spacing branch from cf7c5e5 to d256401 Compare September 3, 2020 13:28
@benlesh benlesh merged commit ea84fc4 into ReactiveX:master Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants