Skip to content

Commit

Permalink
fix(debounceTime): align value emit behavior as same as RxJS4
Browse files Browse the repository at this point in the history
due to current null check, debounceTime does not allow value
to be undefined. This change updates behavior to align behavior
as same as RxJS4 does.

closes #1081
  • Loading branch information
kwonoj committed Dec 16, 2015
1 parent 6303558 commit 5ee11e0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/operator/debounceTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class DebounceTimeOperator<T, R> implements Operator<T, R> {

class DebounceTimeSubscriber<T> extends Subscriber<T> {
private debouncedSubscription: Subscription<any> = null;
private lastValue: any = null;
private lastValue: T = null;
private hasValue: boolean = false;

constructor(destination: Subscriber<T>,
private dueTime: number,
Expand All @@ -31,6 +32,7 @@ class DebounceTimeSubscriber<T> extends Subscriber<T> {
_next(value: T) {
this.clearDebounce();
this.lastValue = value;
this.hasValue = true;
this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
}

Expand All @@ -41,9 +43,11 @@ class DebounceTimeSubscriber<T> extends Subscriber<T> {

debouncedNext(): void {
this.clearDebounce();
if (this.lastValue != null) {

if (this.hasValue) {
this.destination.next(this.lastValue);
this.lastValue = null;
this.hasValue = false;
}
}

Expand Down

0 comments on commit 5ee11e0

Please sign in to comment.