Skip to content

Commit

Permalink
fix(debounce): Fix debounce to unsubscribe duration Observables
Browse files Browse the repository at this point in the history
Fix debounce operator to unsubscribe the ongoing duration Observable if the outer subscriber gets a
new 'next' value. Also fix the clearDebounce() method which was doing a null check, and is now doing
a truthyness check, to catch also undefined cases.
  • Loading branch information
staltz authored and kwonoj committed Nov 13, 2015
1 parent f392a27 commit dea7847
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/operators/debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class DebounceSubscriber<T> extends Subscriber<T> {
}

this.lastValue = value;
this.clearDebounce();
this.add(this.debouncedSubscription = debounce._subscribe(new DurationSelectorSubscriber(this, currentIndex)));
}
}
Expand All @@ -67,7 +68,8 @@ class DebounceSubscriber<T> extends Subscriber<T> {
private clearDebounce(): void {
const debouncedSubscription = this.debouncedSubscription;

if (debouncedSubscription !== null) {
if (debouncedSubscription) {
debouncedSubscription.unsubscribe();
this.remove(debouncedSubscription);
this.debouncedSubscription = null;
}
Expand Down

0 comments on commit dea7847

Please sign in to comment.