Skip to content

Commit

Permalink
help cleaning race when leaving
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Hermann committed Nov 14, 2024
1 parent 40ad2fe commit d9216d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/pages/race/race.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, inject, type OnInit, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject, OnDestroy, type OnInit, signal } from '@angular/core';
import { Game } from '../../game/game';
import { SettingsService } from '../../common/services/settings.service';
import { Router } from '@angular/router';
Expand Down Expand Up @@ -76,7 +76,7 @@ class RaceRanking {
styleUrl: './race.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class RaceComponent extends Destroyable implements OnInit {
export class RaceComponent extends Destroyable implements OnInit, OnDestroy{
private router = inject(Router);
private localEventService = inject(LocalEventService);
private trackService = inject(TrackService);
Expand Down Expand Up @@ -110,6 +110,11 @@ export class RaceComponent extends Destroyable implements OnInit {
.subscribe();
}

public override ngOnDestroy(): void {
this.game?.stop();
this.game = undefined;
}

protected exitRace(): void {
this.game!.stop();
this.game = undefined;
Expand Down

0 comments on commit d9216d8

Please sign in to comment.