diff --git a/spec/operators/windowTime-spec.js b/spec/operators/windowTime-spec.js index 8c21eb4216..6ea4f6ba65 100644 --- a/spec/operators/windowTime-spec.js +++ b/spec/operators/windowTime-spec.js @@ -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); }); diff --git a/src/operator/windowTime.ts b/src/operator/windowTime.ts index 968bdc7ec2..bf68d4a4b1 100644 --- a/src/operator/windowTime.ts +++ b/src/operator/windowTime.ts @@ -55,7 +55,10 @@ class WindowTimeSubscriber extends Subscriber { 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); + } } } @@ -70,7 +73,10 @@ class WindowTimeSubscriber extends Subscriber { 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(); }