Skip to content

Commit

Permalink
fix(windowTime): does not emit on unsubscribed window
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj authored and benlesh committed Feb 9, 2016
1 parent 6d08705 commit 595f4ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 2 additions & 5 deletions spec/operators/windowTime-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,9 @@ describe('Observable.prototype.windowTime', function () {
expectObservable(result, unsub).toBe(expected, values);
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
rxTestScheduler.schedule(function () {
try {
expect(function () {
window.subscribe();
}
catch (err) {
expect(err.message).toBe('Cannot subscribe to a disposed Subject.');
}
}).toThrow(new Rx.ObjectUnsubscribedError());
}, 150);
});

Expand Down
10 changes: 8 additions & 2 deletions src/operator/windowTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
const windows = this.windows;
const len = windows.length;
for (let i = 0; i < len; i++) {
windows[i].next(value);
const window = windows[i];
if (!window.isUnsubscribed) {
window.next(value);
}
}
}

Expand All @@ -70,7 +73,10 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
protected _complete() {
const windows = this.windows;
while (windows.length > 0) {
windows.shift().complete();
const window = windows.shift();
if (!window.isUnsubscribed) {
window.complete();
}
}
this.destination.complete();
}
Expand Down

0 comments on commit 595f4ef

Please sign in to comment.