@@ -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> {
174174function 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