From 595f4ef39115b29e77baf2f85c9a978e3d5ec88a Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Mon, 8 Feb 2016 12:04:04 -0800 Subject: [PATCH] fix(windowTime): does not emit on unsubscribed window --- spec/operators/windowTime-spec.js | 7 ++----- src/operator/windowTime.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) 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(); }