@@ -32,7 +32,6 @@ const MINIMUM_COLUMN_WIDTH = 136;
32
32
*/
33
33
@Injectable ( )
34
34
export class IGridAPIService < T extends IGridBaseComponent > {
35
-
36
35
public change : Subject < any > = new Subject < any > ( ) ;
37
36
protected state : Map < string , T > = new Map < string , T > ( ) ;
38
37
protected editCellState : Map < string , any > = new Map < string , any > ( ) ;
@@ -113,9 +112,12 @@ export class IGridAPIService <T extends IGridBaseComponent> {
113
112
114
113
public on_after_view_init ( id : string ) {
115
114
const grid = this . get ( id ) ;
116
- this . zone . runOutsideAngular ( ( ) => {
117
- this . document . defaultView . addEventListener ( 'resize' , this . resizeHandler ) ;
118
- } ) ;
115
+ // Subscribe only if we haven't got any active subscribtions
116
+ if ( this . state . size === 0 ) {
117
+ this . zone . runOutsideAngular ( ( ) => {
118
+ this . document . defaultView . addEventListener ( 'resize' , this . resizeHandler ) ;
119
+ } ) ;
120
+ }
119
121
this . calculate_grid_width ( id ) ;
120
122
this . init_pinning ( id ) ;
121
123
grid . reflow ( ) ;
@@ -154,9 +156,11 @@ export class IGridAPIService <T extends IGridBaseComponent> {
154
156
}
155
157
156
158
public on_destroy ( id : string ) {
157
- this . zone . runOutsideAngular ( ( ) => {
158
- this . document . defaultView . removeEventListener ( 'resize' , this . resizeHandler ) ;
159
- } ) ;
159
+ if ( this . state . size === 1 ) {
160
+ this . zone . runOutsideAngular ( ( ) => {
161
+ this . document . defaultView . removeEventListener ( 'resize' , this . resizeHandler ) ;
162
+ } ) ;
163
+ }
160
164
this . get_destroy ( id ) . next ( true ) ;
161
165
this . get_destroy ( id ) . complete ( ) ;
162
166
this . unset ( id ) ;
@@ -380,7 +384,7 @@ export class IGridAPIService <T extends IGridBaseComponent> {
380
384
}
381
385
}
382
386
383
- public sort_implementation ( id : string , fieldName : string , dir : SortingDirection , ignoreCase : boolean ) : void {
387
+ private sort_implementation ( id : string , fieldName : string , dir : SortingDirection , ignoreCase : boolean ) : void {
384
388
if ( dir === SortingDirection . None ) {
385
389
this . remove_grouping_expression ( id , fieldName ) ;
386
390
}
@@ -390,7 +394,7 @@ export class IGridAPIService <T extends IGridBaseComponent> {
390
394
this . get ( id ) . sortingExpressions = sortingState ;
391
395
}
392
396
393
- public sort_multiple_implementation ( id : string , expressions : ISortingExpression [ ] ) : void {
397
+ private sort_multiple_implementation ( id : string , expressions : ISortingExpression [ ] ) : void {
394
398
const sortingState = cloneArray ( this . get ( id ) . sortingExpressions ) ;
395
399
396
400
for ( const each of expressions ) {
@@ -472,7 +476,7 @@ export class IGridAPIService <T extends IGridBaseComponent> {
472
476
this . clear_filter_implementation ( id , fieldName ) ;
473
477
}
474
478
475
- public clear_filter_implementation ( id : string , fieldName : string ) {
479
+ private clear_filter_implementation ( id : string , fieldName : string ) {
476
480
if ( fieldName ) {
477
481
const column = this . get_column_by_name ( id , fieldName ) ;
478
482
if ( ! column ) {
@@ -509,7 +513,7 @@ export class IGridAPIService <T extends IGridBaseComponent> {
509
513
this . clear_sort_implementation ( id , fieldName ) ;
510
514
}
511
515
512
- public clear_sort_implementation ( id , fieldName ) {
516
+ private clear_sort_implementation ( id , fieldName ) {
513
517
const sortingState = this . get ( id ) . sortingExpressions ;
514
518
const index = sortingState . findIndex ( ( expr ) => expr . fieldName === fieldName ) ;
515
519
if ( index > - 1 ) {
@@ -1125,7 +1129,7 @@ export class IGridAPIService <T extends IGridBaseComponent> {
1125
1129
}
1126
1130
1127
1131
private subscribe_next ( virtualContainer : any , callback : ( elem ?) => void ) {
1128
- virtualContainer . onChunkLoad . pipe ( take ( 1 ) ) . subscribe ( {
1132
+ const subscription = virtualContainer . onChunkLoad . pipe ( take ( 1 ) ) . subscribe ( {
1129
1133
next : ( e : any ) => {
1130
1134
callback ( e ) ;
1131
1135
}
0 commit comments