Skip to content

Commit

Permalink
fix(throttleTime): feedback from @Parakleta - schedule timer before e…
Browse files Browse the repository at this point in the history
…mitting value
  • Loading branch information
sod committed Sep 26, 2017
1 parent ade1c0e commit 9cda512
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/operators/throttleTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class ThrottleTimeSubscriber<T> extends Subscriber<T> {

protected _next(value: T) {
if (!this.throttled && this.leading) {
this.throttle();
this.destination.next(value);
} else if (this.trailing) {
this._trailingValue = value;
Expand All @@ -110,10 +111,11 @@ class ThrottleTimeSubscriber<T> extends Subscriber<T> {
this.throttled = null;

if (this.trailing && this._hasTrailingValue) {
this.destination.next(this._trailingValue);
const trailingValue = this._trailingValue;
this._trailingValue = null;
this._hasTrailingValue = false;
this.throttle();
this.destination.next(trailingValue);
}
}
}
Expand Down

0 comments on commit 9cda512

Please sign in to comment.