1- import { Component } from '@angular/core'
1+ import { Component , inject , OnDestroy , OnInit } from '@angular/core'
22import { MatButton , MatFabButton } from '@angular/material/button'
33import { RouterLink } from '@angular/router'
44import {
99} from '@angular/material/expansion'
1010import { MatCardModule } from '@angular/material/card'
1111import { MatIconModule } from '@angular/material/icon'
12+ import { HealthService } from '../../services/health-service'
13+ import { Subscription } from 'rxjs'
14+ import { environment } from '../../../environments/environment'
1215
1316@Component ( {
1417 selector : 'app-welcome-page' ,
@@ -26,4 +29,17 @@ import { MatIconModule } from '@angular/material/icon'
2629 templateUrl : './welcome-page.html' ,
2730 styleUrl : './welcome-page.css' ,
2831} )
29- export class WelcomePage { }
32+ export class WelcomePage implements OnInit , OnDestroy {
33+ private readonly healthService = inject ( HealthService )
34+ subscription : Subscription [ ] = [ ]
35+
36+ ngOnInit ( ) {
37+ if ( environment . production ) {
38+ this . subscription . push ( this . healthService . updateStat ( ) . subscribe ( ) )
39+ }
40+ }
41+
42+ ngOnDestroy ( ) {
43+ this . subscription . forEach ( ( sub ) => sub . unsubscribe ( ) )
44+ }
45+ }
0 commit comments