-
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
Throttle fix #2864
Throttle fix #2864
Conversation
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need test cases for seems not needed maybe.{ leading: true, trailing: false }
?
Was something wrong with #2749? |
@sod nope... I just didn't see it. sorry. |
Okay, @sod I've reviewed your PR. there were a lot of changes I requested, if you think you can knock those out, that would be great. I'll just ween this PR down to only be the |
BREAKING CHANGES: This changes the behavior of throttle, in particular throttling with both leading and trailing behaviors set to true, to more closely match the throttling behavior of lodash and other libraries. Throttling now starts immediately after any emission from the observable, and values will not be double emitted for both leading and trailing values. fixes #2859
This has the same problem that #2749 had initially in that it defers the setup of the throttle observable until after emitting the value, and this can lead to drift in the throttling. I think it needs to look something like: protected _next(value: T): void {
this._hasValue = true;
this._sendValue = value;
if (!this._throttled) {
this.throttle(this._leading);
}
}
private throttle(doSend: boolean) {
const { _hasValue, _sendValue } = this;
if (!_hasValue) return;
let duration, err;
try {
duration = this.durationSelector(_sendValue);
} catch (e) {
err = e;
}
if (doSend) {
this.destination.next(_sendValue);
this._hasValue = false;
this._sendValue = null;
}
if (err != null) {
this.destination.error(err);
} else {
this.add(this._throttled = subscribeToResult(this, duration));
}
}
private throttlingDone() {
const { _throttled, _trailing } = this;
if (_throttled) {
_throttled.unsubscribe();
}
this._throttled = null;
if (_trailing) {
this.throttle(true);
}
} The |
Whats up with this PR? |
it needs to be rebased, and I haven't gotten back around to it. |
@benlesh thanks for the response. will it be possible to get this into Version 6.0.0? Can I support by rebasing your commit? |
@micha149 Yeah, we're going to get this in. Feel free to rebase if you have the time. |
@benlesh I rebased the commit. As far as I know I'm not able to get it into this PR. You can pull from here: micha149@df689e5 |
This still doesn't deal with the issue that a slow |
BREAKING CHANGES: This changes the behavior of throttle, in particular throttling with both leading and trailing behaviors set to true, to more closely match the throttling behavior of lodash and other libraries. Throttling now starts immediately after any emission from the observable, and values will not be double emitted for both leading and trailing values closes ReactiveX#2864
Changes coped to #3505 |
…3505) BREAKING CHANGES: This changes the behavior of throttle, in particular throttling with both leading and trailing behaviors set to true, to more closely match the throttling behavior of lodash and other libraries. Throttling now starts immediately after any emission from the observable, and values will not be double emitted for both leading and trailing values closes #2864
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
To address #2859