toSignal via Gemini

This commit is contained in:
2026-08-18 07:55:54 +00:00
parent 59eb45da96
commit 993f83c786
350 changed files with 6231 additions and 9801 deletions
+9 -11
View File
@@ -1,5 +1,5 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpHeaders, httpResource, HttpResourceRef } from '@angular/common/http';
import { Injectable, Signal, inject } from '@angular/core';
import { Observable } from 'rxjs';
import { catchError } from 'rxjs/operators';
@@ -19,17 +19,15 @@ export class TaxService {
private http = inject(HttpClient);
private log = inject(ErrorLoggerService);
get(id: string | null): Observable<Tax> {
const getUrl: string = id === null ? url : `${url}/${id}`;
return this.http
.get<Tax>(getUrl)
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Tax>;
get(id: Signal<string | null> | string | null): HttpResourceRef<Tax | undefined> {
return httpResource<Tax>(() => {
const idVal = typeof id === 'function' ? id() : id;
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
});
}
list(): Observable<Tax[]> {
return this.http
.get<Tax[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Tax[]>;
list(): HttpResourceRef<Tax[] | undefined> {
return httpResource<Tax[]>(() => `${url}/list`);
}
save(tax: Tax): Observable<Tax> {