From b73e260a353f6f2e52672789f82ff4328af17755 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Wed, 9 Dec 2015 14:20:45 +0200 Subject: [PATCH] fix(windowTime): fix windowTime to dispose window Subjects Fix windowTime() operator to dispose window Subjects when the destination Subscriber is unsubscribed. --- src/operator/windowTime.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/operator/windowTime.ts b/src/operator/windowTime.ts index 425922d74e..d398dd0e88 100644 --- a/src/operator/windowTime.ts +++ b/src/operator/windowTime.ts @@ -19,7 +19,7 @@ class WindowTimeOperator implements Operator { private scheduler: Scheduler) { } - call(subscriber: Subscriber): Subscriber { + call(subscriber: Subscriber>): Subscriber { return new WindowTimeSubscriber( subscriber, this.windowTimeSpan, this.windowCreationInterval, this.scheduler ); @@ -29,7 +29,7 @@ class WindowTimeOperator implements Operator { class WindowTimeSubscriber extends Subscriber { private windows: Subject[] = []; - constructor(destination: Subscriber, + constructor(protected destination: Subscriber>, private windowTimeSpan: number, private windowCreationInterval: number, private scheduler: Scheduler) { @@ -72,9 +72,11 @@ class WindowTimeSubscriber extends Subscriber { } openWindow(): Subject { - let window = new Subject(); + const window = new Subject(); this.windows.push(window); - this.destination.next(window); + const destination = this.destination; + destination.add(window); + destination.next(window); return window; }