1
- import { Component , OnInit } from '@angular/core' ;
1
+ import { Component , OnInit , OnDestroy } from '@angular/core' ;
2
2
import { SettingsService } from '../../settings/settings.service' ;
3
3
import { TabService } from '../../tabs/tab.service' ;
4
4
import { TimoneerTabs } from '../../timoneer-tabs' ;
5
+ import { Subject } from 'rxjs' ;
6
+ import { takeUntil } from 'rxjs/operators' ;
5
7
6
8
@Component ( {
7
9
selector : 'tim-registry-cards' ,
8
10
templateUrl : './registry-cards.component.html' ,
9
11
styleUrls : [ './registry-cards.component.scss' ]
10
12
} )
11
- export class RegistryCardsComponent implements OnInit {
13
+ export class RegistryCardsComponent implements OnInit , OnDestroy {
12
14
13
15
public loading : boolean ;
14
16
15
17
public registries : { name : string , url : string } [ ] ;
18
+ private componetDestroyed = new Subject ( ) ;
16
19
17
20
constructor ( private settingsService : SettingsService ,
18
21
private tabService : TabService ) { }
19
22
20
23
public ngOnInit ( ) {
21
24
25
+ this . registries = [ ] ;
22
26
this . loading = true ;
23
27
this . settingsService . getSettings ( )
28
+ . pipe ( takeUntil ( this . componetDestroyed ) )
24
29
. subscribe ( settings => {
25
30
this . registries = settings . registries
26
31
. filter ( r => r . allowsCatalog )
@@ -42,4 +47,9 @@ export class RegistryCardsComponent implements OnInit {
42
47
params : registry
43
48
} ) ;
44
49
}
50
+
51
+ public ngOnDestroy ( ) {
52
+ this . componetDestroyed . next ( ) ;
53
+ this . componetDestroyed . unsubscribe ( ) ;
54
+ }
45
55
}
0 commit comments