Skip to content

Commit d4533c4

Browse files
kwonojbenlesh
authored andcommitted
fix(windowTime): ensure windows created when only a timespan is passed are closed and cleaned up properly. (#2278)
1 parent c65a098 commit d4533c4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/operator/windowTime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
113113
private windowCreationInterval: number,
114114
private scheduler: IScheduler) {
115115
super(destination);
116+
117+
const window = this.openWindow();
116118
if (windowCreationInterval !== null && windowCreationInterval >= 0) {
117-
let window = this.openWindow();
118119
const closeState: CloseState<T> = { subscriber: this, window, context: <any>null };
119120
const creationState: CreationState<T> = { windowTimeSpan, windowCreationInterval, subscriber: this, scheduler };
120121
this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
121122
this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
122123
} else {
123-
let window = this.openWindow();
124124
const timeSpanOnlyState: TimeSpanOnlyState<T> = { subscriber: this, window, windowTimeSpan };
125125
this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
126126
}
@@ -174,7 +174,7 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
174174
function dispatchWindowTimeSpanOnly<T>(this: Action<TimeSpanOnlyState<T>>, state: TimeSpanOnlyState<T>): void {
175175
const { subscriber, windowTimeSpan, window } = state;
176176
if (window) {
177-
window.complete();
177+
subscriber.closeWindow(window);
178178
}
179179
state.window = subscriber.openWindow();
180180
this.schedule(state, windowTimeSpan);

0 commit comments

Comments
 (0)