Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
popcodelab committed Apr 13, 2024
2 parents a495a8f + 85a19c3 commit a37bfb2
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {take} from 'rxjs';
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Subscription, take} from 'rxjs';
import {DataService} from './core/services/data.service';

/**
Expand All @@ -16,7 +16,14 @@ import {DataService} from './core/services/data.service';
styleUrls: ['./app.component.scss'],
})

export class AppComponent implements OnInit {
export class AppComponent implements OnInit, OnDestroy {

/**
* Represents a subscription.
*
* @type {Subscription} subscription
*/
private subscription: Subscription | undefined;

/**
* Creates a new instance of the ClassName.
Expand All @@ -27,12 +34,26 @@ export class AppComponent implements OnInit {
constructor(private olympicService: DataService) {
}

/**
* Lifecycle hook that is called when a component is being destroyed.
* This method is part of the Angular component lifecycle, triggered just before the component is removed from the view.
* It is used to perform any necessary cleanup tasks, such as unsubscribing from observable or resetting variables.
*
* @returns {void}
* This method does not return anything.
*/
ngOnDestroy(): void {
if (this.subscription) {
this.subscription.unsubscribe();
}
}

/**
* Initializes the component.
*
* @returns {void}
*/
ngOnInit(): void {
this.olympicService.loadInitialData().pipe(take(1)).subscribe();
this.subscription = this.olympicService.loadInitialData().pipe(take(1)).subscribe();
}
}

0 comments on commit a37bfb2

Please sign in to comment.