diff --git a/src/operator/windowTime.ts b/src/operator/windowTime.ts index 4e8b2746d4..3c563ee719 100644 --- a/src/operator/windowTime.ts +++ b/src/operator/windowTime.ts @@ -113,14 +113,14 @@ class WindowTimeSubscriber extends Subscriber { private windowCreationInterval: number, private scheduler: IScheduler) { super(destination); + + const window = this.openWindow(); if (windowCreationInterval !== null && windowCreationInterval >= 0) { - let window = this.openWindow(); const closeState: CloseState = { subscriber: this, window, context: null }; const creationState: CreationState = { windowTimeSpan, windowCreationInterval, subscriber: this, scheduler }; this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState)); this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState)); } else { - let window = this.openWindow(); const timeSpanOnlyState: TimeSpanOnlyState = { subscriber: this, window, windowTimeSpan }; this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState)); } @@ -174,7 +174,7 @@ class WindowTimeSubscriber extends Subscriber { function dispatchWindowTimeSpanOnly(this: Action>, state: TimeSpanOnlyState): void { const { subscriber, windowTimeSpan, window } = state; if (window) { - window.complete(); + subscriber.closeWindow(window); } state.window = subscriber.openWindow(); this.schedule(state, windowTimeSpan);