Skip to content

Commit

Permalink
fix(windowTime): ensure windows created when only a timespan is passe…
Browse files Browse the repository at this point in the history
…d are closed and cleaned up properly. (#2278)
  • Loading branch information
kwonoj authored and benlesh committed Jan 29, 2017
1 parent c65a098 commit d4533c4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/operator/windowTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
private windowCreationInterval: number,
private scheduler: IScheduler) {
super(destination);

const window = this.openWindow();
if (windowCreationInterval !== null && windowCreationInterval >= 0) {
let window = this.openWindow();
const closeState: CloseState<T> = { subscriber: this, window, context: <any>null };
const creationState: CreationState<T> = { 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<T> = { subscriber: this, window, windowTimeSpan };
this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
}
Expand Down Expand Up @@ -174,7 +174,7 @@ class WindowTimeSubscriber<T> extends Subscriber<T> {
function dispatchWindowTimeSpanOnly<T>(this: Action<TimeSpanOnlyState<T>>, state: TimeSpanOnlyState<T>): void {
const { subscriber, windowTimeSpan, window } = state;
if (window) {
window.complete();
subscriber.closeWindow(window);
}
state.window = subscriber.openWindow();
this.schedule(state, windowTimeSpan);
Expand Down

0 comments on commit d4533c4

Please sign in to comment.