Skip to content

Commit 5ee11e0

Browse files
committed
fix(debounceTime): align value emit behavior as same as RxJS4
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
1 parent 6303558 commit 5ee11e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/operator/debounceTime.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class DebounceTimeOperator<T, R> implements Operator<T, R> {
2020

2121
class DebounceTimeSubscriber<T> extends Subscriber<T> {
2222
private debouncedSubscription: Subscription<any> = null;
23-
private lastValue: any = null;
23+
private lastValue: T = null;
24+
private hasValue: boolean = false;
2425

2526
constructor(destination: Subscriber<T>,
2627
private dueTime: number,
@@ -31,6 +32,7 @@ class DebounceTimeSubscriber<T> extends Subscriber<T> {
3132
_next(value: T) {
3233
this.clearDebounce();
3334
this.lastValue = value;
35+
this.hasValue = true;
3436
this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
3537
}
3638

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

4244
debouncedNext(): void {
4345
this.clearDebounce();
44-
if (this.lastValue != null) {
46+
47+
if (this.hasValue) {
4548
this.destination.next(this.lastValue);
4649
this.lastValue = null;
50+
this.hasValue = false;
4751
}
4852
}
4953

0 commit comments

Comments
 (0)