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 committed Feb 8, 2016
1 parent 989a14e commit e7cbe88
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 @@ -51,7 +51,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 @@ -66,7 +69,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 e7cbe88

Please sign in to comment.