feat: add stock keeping units list component and related services
feat: implement checkbox component with label and hint support feat: create sale invoice full response model for invoice details feat: add single view component for displaying sale invoice details feat: define various list configurations for account, business activity, and consumer management feat: establish list configurations for managing devices, goods, and licenses feat: create list configurations for managing partners and their accounts feat: implement user management list configuration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, shareReplay } from 'rxjs';
|
||||
import { ENUMS_API_ROUTES } from './constants/apiRoutes';
|
||||
import { TEnumApi } from './models';
|
||||
import { IApiEnumResponse } from './models/io';
|
||||
@@ -10,8 +10,19 @@ export class EnumsService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
private apiRoutes = ENUMS_API_ROUTES;
|
||||
private readonly cache = new Map<TEnumApi, Observable<IApiEnumResponse[]>>();
|
||||
|
||||
getAll(type: TEnumApi): Observable<IApiEnumResponse[]> {
|
||||
return this.http.get<IApiEnumResponse[]>(this.apiRoutes[type]);
|
||||
const cached = this.cache.get(type);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const request$ = this.http
|
||||
.get<IApiEnumResponse[]>(this.apiRoutes[type])
|
||||
.pipe(shareReplay({ bufferSize: 1, refCount: true }));
|
||||
|
||||
this.cache.set(type, request$);
|
||||
return request$;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user