import { type Signal } from "@angular/core"; import type { ApiError, UrlOptions } from "../../types/index.js"; /** Reactive state exposed by the {@link useRequest} factory (Angular signals). */ export interface RequestState { data: Signal; error: Signal; loading: Signal; refetch: () => Promise; } /** * Angular signal factory that wraps KatanaKit's HTTP GET. Bridges the Safe * Result pattern to Angular signals and never throws on HTTP errors. * * Must be called within an injection context (component field initializer, * constructor, or service) so it can abort in-flight requests via `DestroyRef`. * Stale responses are ignored via a request version counter. * * @param apiName - Name of the registered API (see `useInitApis`). * @param endpointName - Name of the endpoint inside that API. * @param options - Optional `UrlOptions` (path/query params). * @returns Signals `{ data, error, loading }` plus `refetch`. * * @example * ```ts * import { Component } from "@angular/core"; * import { useRequest } from "katanakit-js/adapters/angular"; * * @Component({ selector: "app-pokemon", template: `@if (loading()) { Loading… } @else { {{ data()?.name }} }` }) * export class PokemonComponent { * readonly result = useRequest<{ name: string }>("pokeapi", "pokemonById", { params: { id: 25 } }); * readonly data = this.result.data; * readonly loading = this.result.loading; * } * ``` */ export declare function useRequest(apiName: string, endpointName: string, options?: UrlOptions): RequestState; //# sourceMappingURL=fetch.d.ts.map