account Komponente
This commit is contained in:
@@ -2,39 +2,36 @@ import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable, debounceTime, distinctUntilChanged, map, shareReplay } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LoadingService {
|
||||
public loading$ = new BehaviorSubject<string[]>([]);
|
||||
|
||||
private loadingTextSubject = new BehaviorSubject<string | null>(null);
|
||||
loadingText$: Observable<string | null> = this.loadingTextSubject.asObservable();
|
||||
public loading$ = new BehaviorSubject<string[]>([]);
|
||||
|
||||
public isLoading$ = this.loading$.asObservable().pipe(
|
||||
map((loading) => loading.length > 0),
|
||||
debounceTime(200),
|
||||
distinctUntilChanged(),
|
||||
shareReplay(1)
|
||||
);
|
||||
private loadingTextSubject = new BehaviorSubject<string | null>(null);
|
||||
loadingText$: Observable<string | null> = this.loadingTextSubject.asObservable();
|
||||
|
||||
public startLoading(type: string,request?:string): void {
|
||||
if (!this.loading$.value.includes(type)) {
|
||||
this.loading$.next(this.loading$.value.concat(type));
|
||||
if (type==='uploadImage'
|
||||
|| request?.includes('uploadPropertyPicture')
|
||||
|| request?.includes('uploadProfile')
|
||||
|| request?.includes('uploadCompanyLogo')) {
|
||||
this.loadingTextSubject.next("Please wait - we're processing your image...");
|
||||
} else {
|
||||
this.loadingTextSubject.next(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
public isLoading$ = this.loading$.asObservable().pipe(
|
||||
map(loading => loading.length > 0),
|
||||
debounceTime(200),
|
||||
distinctUntilChanged(),
|
||||
shareReplay(1),
|
||||
);
|
||||
|
||||
public stopLoading(type: string): void {
|
||||
if (this.loading$.value.includes(type)) {
|
||||
this.loading$.next(this.loading$.value.filter((t) => t !== type));
|
||||
this.loadingTextSubject.next(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
public startLoading(type: string, request?: string): void {
|
||||
if (!this.loading$.value.includes(type)) {
|
||||
this.loading$.next(this.loading$.value.concat(type));
|
||||
if (type === 'uploadImage' || request?.includes('uploadImage') || request?.includes('uploadPropertyPicture') || request?.includes('uploadProfile') || request?.includes('uploadCompanyLogo')) {
|
||||
this.loadingTextSubject.next("Please wait - we're processing your image...");
|
||||
} else {
|
||||
this.loadingTextSubject.next(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public stopLoading(type: string): void {
|
||||
if (this.loading$.value.includes(type)) {
|
||||
this.loading$.next(this.loading$.value.filter(t => t !== type));
|
||||
this.loadingTextSubject.next(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user