Skip to content

Commit

Permalink
Creating a service to handle time countering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabri432 committed Mar 31, 2024
1 parent 4da636a commit d9ecade
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/services/timeCounter.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class CounterService {
async countForMinute(updateCallback: (count: number) => void): Promise<void> {
const endTime = 60;

for (let count = 0; count <= endTime; count++) {
updateCallback(endTime - count);
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
}

0 comments on commit d9ecade

Please sign in to comment.