LoadingStatusService
The loading status service keeps track of loading tasks. This state is used to show a load spinner overlay when loading is in progress.
export class MyComponent {
private loadingStatusService = inject(LoadingStatusService)
async task() {
// Create a new loading task
const task = this.loadingStatusService.startTask("my new task")
// Set the state to `LOADING` to start the
task.setIsLoading()
try {
await doTask()
// Set the state to `LOADED`
task.setIsLoaded()
} catch (e) {
// Set the state to `ERROR`
task.setIsError(e)
}
}
}