add map each and query params to get method

This commit is contained in:
Dan Percic 2021-10-06 14:16:48 +03:00
parent 56ef15eecb
commit eca1fd1b9c
2 changed files with 6 additions and 2 deletions

View File

@ -31,11 +31,11 @@ export abstract class GenericService<I> {
return id ? this._getOne([id]) : this.getAll();
}
@Validate()
getAll<R = I[]>(modelPath = this._defaultModelPath): Observable<R> {
getAll<R = I[]>(modelPath = this._defaultModelPath, queryParams?: List<QueryParam>): Observable<R> {
return this._http.get<R>(`/${encodeURI(modelPath)}`, {
headers: HeadersConfiguration.getHeaders({ contentType: false }),
observe: 'body',
params: this._queryParams(queryParams),
});
}

View File

@ -9,5 +9,9 @@ export function any<T>(predicate: (value: T, index: number) => boolean): Operato
return map(entities => entities.some(predicate));
}
export function mapEach<T, R>(predicate: (value: T, index: number) => R): OperatorFunction<T[], R[]> {
return map(entities => entities.map(predicate));
}
export const toLengthValue = (entities: unknown[]): number => entities?.length ?? 0;
export const getLength = pipe(map(toLengthValue), distinctUntilChanged());