@@ -23,15 +23,18 @@ class WindowCountSubscriber<T> extends Subscriber<T> {
23
23
private windows : Subject < T > [ ] = [ new Subject < T > ( ) ] ;
24
24
private count : number = 0 ;
25
25
26
- constructor ( destination : Subscriber < Observable < T > > ,
26
+ constructor ( protected destination : Subscriber < Observable < T > > ,
27
27
private windowSize : number ,
28
28
private startWindowEvery : number ) {
29
29
super ( destination ) ;
30
- destination . next ( this . windows [ 0 ] ) ;
30
+ const firstWindow = this . windows [ 0 ] ;
31
+ destination . add ( firstWindow ) ;
32
+ destination . next ( firstWindow ) ;
31
33
}
32
34
33
35
_next ( value : T ) {
34
36
const startWindowEvery = ( this . startWindowEvery > 0 ) ? this . startWindowEvery : this . windowSize ;
37
+ const destination = this . destination ;
35
38
const windowSize = this . windowSize ;
36
39
const windows = this . windows ;
37
40
const len = windows . length ;
@@ -44,9 +47,10 @@ class WindowCountSubscriber<T> extends Subscriber<T> {
44
47
windows . shift ( ) . complete ( ) ;
45
48
}
46
49
if ( ++ this . count % startWindowEvery === 0 ) {
47
- let window = new Subject < T > ( ) ;
50
+ const window = new Subject < T > ( ) ;
48
51
windows . push ( window ) ;
49
- this . destination . next ( window ) ;
52
+ destination . add ( window ) ;
53
+ destination . next ( window ) ;
50
54
}
51
55
}
52
56
0 commit comments