Skip to content

Commit b73e260

Browse files
staltzbenlesh
authored andcommitted
fix(windowTime): fix windowTime to dispose window Subjects
Fix windowTime() operator to dispose window Subjects when the destination Subscriber is unsubscribed.
1 parent 997a501 commit b73e260

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/operator/windowTime.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class WindowTimeOperator<T, R> implements Operator<T, R> {
1919
private scheduler: Scheduler) {
2020
}
2121

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

32-
constructor(destination: Subscriber<T>,
32+
constructor(protected destination: Subscriber<Observable<T>>,
3333
private windowTimeSpan: number,
3434
private windowCreationInterval: number,
3535
private scheduler: Scheduler) {
@@ -72,9 +72,11 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
7272
}
7373

7474
openWindow(): Subject<T> {
75-
let window = new Subject<T>();
75+
const window = new Subject<T>();
7676
this.windows.push(window);
77-
this.destination.next(window);
77+
const destination = this.destination;
78+
destination.add(window);
79+
destination.next(window);
7880
return window;
7981
}
8082

0 commit comments

Comments
 (0)