initial release

This commit is contained in:
2024-02-29 10:23:41 -06:00
commit 5146c8e919
210 changed files with 11040 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, debounceTime, distinctUntilChanged, map, shareReplay } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class LoadingService {
public loading$ = new BehaviorSubject<string[]>([]);
public isLoading$ = this.loading$.asObservable().pipe(
map((loading) => loading.length > 0),
debounceTime(200),
distinctUntilChanged(),
shareReplay(1)
);
public startLoading(type: string): void {
if (!this.loading$.value.includes(type)) {
this.loading$.next(this.loading$.value.concat(type));
}
}
public stopLoading(type: string): void {
if (this.loading$.value.includes(type)) {
this.loading$.next(this.loading$.value.filter((t) => t !== type));
}
}
}