Skip to content

Commit

Permalink
fix(windowTime): fix windowTime to dispose window Subjects
Browse files Browse the repository at this point in the history
Fix windowTime() operator to dispose window Subjects when the destination Subscriber is
unsubscribed.
  • Loading branch information
staltz authored and benlesh committed Dec 14, 2015
1 parent 997a501 commit b73e260
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/operator/windowTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WindowTimeOperator<T, R> implements Operator<T, R> {
private scheduler: Scheduler) {
}

call(subscriber: Subscriber<T>): Subscriber<T> {
call(subscriber: Subscriber<Observable<T>>): Subscriber<T> {
return new WindowTimeSubscriber(
subscriber, this.windowTimeSpan, this.windowCreationInterval, this.scheduler
);
Expand All @@ -29,7 +29,7 @@ class WindowTimeOperator<T, R> implements Operator<T, R> {
class WindowTimeSubscriber<T> extends Subscriber<T> {
private windows: Subject<T>[] = [];

constructor(destination: Subscriber<T>,
constructor(protected destination: Subscriber<Observable<T>>,
private windowTimeSpan: number,
private windowCreationInterval: number,
private scheduler: Scheduler) {
Expand Down Expand Up @@ -72,9 +72,11 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
}

openWindow(): Subject<T> {
let window = new Subject<T>();
const window = new Subject<T>();
this.windows.push(window);
this.destination.next(window);
const destination = this.destination;
destination.add(window);
destination.next(window);
return window;
}

Expand Down

0 comments on commit b73e260

Please sign in to comment.