Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Commit

Permalink
fix(debounce): support scalar selectors (ReactiveX#3236)
Browse files Browse the repository at this point in the history
* test(debounce): add failing scalar selector test

* fix(debounce): support scalar selectors

Closes ReactiveX#3232

* test(debounce): rename and comment test
  • Loading branch information
cartant authored and benlesh committed Jan 19, 2018
1 parent be952c0 commit 1548393
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/operators/debounce-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ describe('Observable.prototype.debounce', () => {
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should support a scalar selector observable', () => {

// If the selector returns a scalar observable, the debounce operator
// should emit the value immediately.

const e1 = hot('--a--bc--d----|');
const e1subs = '^ !';
const expected = '--a--bc--d----|';

expectObservable(e1.debounce(() => Rx.Observable.of(0))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should complete when source does not emit', () => {
const e1 = hot('-----|');
const e1subs = '^ !';
Expand Down
2 changes: 1 addition & 1 deletion src/internal/operators/debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class DebounceSubscriber<T, R> extends OuterSubscriber<T, R> {
}

subscription = subscribeToResult(this, duration);
if (!subscription.closed) {
if (subscription && !subscription.closed) {
this.add(this.durationSubscription = subscription);
}
}
Expand Down

0 comments on commit 1548393

Please sign in to comment.