@@ -8,9 +8,14 @@ import { EnvironmentInjector } from '@angular/core';
88import { EnvironmentProviders } from ' @angular/core' ;
99import * as i0 from ' @angular/core' ;
1010import { InjectionToken } from ' @angular/core' ;
11+ import type { Injector } from ' @angular/core' ;
1112import { ModuleWithProviders } from ' @angular/core' ;
1213import { Observable } from ' rxjs' ;
1314import { Provider } from ' @angular/core' ;
15+ import type { ResourceRef } from ' @angular/core' ;
16+ import type { Signal } from ' @angular/core' ;
17+ import type { ValueEqualityFn } from ' @angular/core' ;
18+ import type { WritableResource } from ' @angular/core' ;
1419import { XhrFactory } from ' @angular/common' ;
1520
1621// @public
@@ -2153,6 +2158,84 @@ export class HttpRequest<T> {
21532158 readonly withCredentials: boolean ;
21542159}
21552160
2161+ // @public
2162+ export const httpResource: HttpResourceFn ;
2163+
2164+ // @public
2165+ export interface HttpResourceFn {
2166+ <TResult = unknown >(url : string | (() => string | undefined ), options : HttpResourceOptions <TResult , unknown > & {
2167+ defaultValue: NoInfer <TResult >;
2168+ }): HttpResourceRef <TResult >;
2169+ <TResult = unknown >(url : string | (() => string | undefined ), options ? : HttpResourceOptions <TResult , unknown >): HttpResourceRef <TResult | undefined >;
2170+ <TResult = unknown >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options : HttpResourceOptions <TResult , unknown > & {
2171+ defaultValue: NoInfer <TResult >;
2172+ }): HttpResourceRef <TResult >;
2173+ <TResult = unknown >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options ? : HttpResourceOptions <TResult , unknown >): HttpResourceRef <TResult | undefined >;
2174+ arrayBuffer: {
2175+ <TResult = ArrayBuffer >(url : string | (() => string | undefined ), options : HttpResourceOptions <TResult , ArrayBuffer > & {
2176+ defaultValue: NoInfer <TResult >;
2177+ }): HttpResourceRef <TResult >;
2178+ <TResult = ArrayBuffer >(url : string | (() => string | undefined ), options ? : HttpResourceOptions <TResult , ArrayBuffer >): HttpResourceRef <TResult | undefined >;
2179+ <TResult = ArrayBuffer >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options : HttpResourceOptions <TResult , ArrayBuffer > & {
2180+ defaultValue: NoInfer <TResult >;
2181+ }): HttpResourceRef <TResult >;
2182+ <TResult = ArrayBuffer >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options ? : HttpResourceOptions <TResult , ArrayBuffer >): HttpResourceRef <TResult | undefined >;
2183+ };
2184+ blob: {
2185+ <TResult = Blob >(url : string | (() => string | undefined ), options : HttpResourceOptions <TResult , Blob > & {
2186+ defaultValue: NoInfer <TResult >;
2187+ }): HttpResourceRef <TResult >;
2188+ <TResult = Blob >(url : string | (() => string | undefined ), options ? : HttpResourceOptions <TResult , Blob >): HttpResourceRef <TResult | undefined >;
2189+ <TResult = Blob >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options : HttpResourceOptions <TResult , Blob > & {
2190+ defaultValue: NoInfer <TResult >;
2191+ }): HttpResourceRef <TResult >;
2192+ <TResult = Blob >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options ? : HttpResourceOptions <TResult , Blob >): HttpResourceRef <TResult | undefined >;
2193+ };
2194+ text: {
2195+ <TResult = string >(url : string | (() => string | undefined ), options : HttpResourceOptions <TResult , string > & {
2196+ defaultValue: NoInfer <TResult >;
2197+ }): HttpResourceRef <TResult >;
2198+ <TResult = string >(url : string | (() => string | undefined ), options ? : HttpResourceOptions <TResult , string >): HttpResourceRef <TResult | undefined >;
2199+ <TResult = string >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options : HttpResourceOptions <TResult , string > & {
2200+ defaultValue: NoInfer <TResult >;
2201+ }): HttpResourceRef <TResult >;
2202+ <TResult = string >(request : HttpResourceRequest | (() => HttpResourceRequest | undefined ), options ? : HttpResourceOptions <TResult , string >): HttpResourceRef <TResult | undefined >;
2203+ };
2204+ }
2205+
2206+ // @public
2207+ export interface HttpResourceOptions <TResult , TRaw > {
2208+ defaultValue? : NoInfer <TResult >;
2209+ equal? : ValueEqualityFn <NoInfer <TResult >>;
2210+ injector? : Injector ;
2211+ map? : (value : TRaw ) => TResult ;
2212+ }
2213+
2214+ // @public
2215+ export interface HttpResourceRef <T > extends WritableResource <T >, ResourceRef <T > {
2216+ // (undocumented)
2217+ destroy(): void ;
2218+ // (undocumented)
2219+ hasValue(): this is HttpResourceRef <Exclude <T , undefined >>;
2220+ readonly headers: Signal <HttpHeaders | undefined >;
2221+ readonly progress: Signal <HttpProgressEvent | undefined >;
2222+ readonly statusCode: Signal <number | undefined >;
2223+ }
2224+
2225+ // @public
2226+ export interface HttpResourceRequest {
2227+ body? : unknown ;
2228+ headers? : HttpHeaders | Record <string , string | ReadonlyArray <string >>;
2229+ method? : string ;
2230+ params? : HttpParams | Record <string , string | number | boolean | ReadonlyArray <string | number | boolean >>;
2231+ reportProgress? : boolean ;
2232+ transferCache? : {
2233+ includeHeaders? : string [];
2234+ } | boolean ;
2235+ url: string ;
2236+ withCredentials? : boolean ;
2237+ }
2238+
21562239// @public
21572240export class HttpResponse <T > extends HttpResponseBase {
21582241 constructor (init ? : {
0 commit comments