import { HttpResourceOptions } from '@angular/common/http'; import { Signal, ResourceRef } from '@angular/core'; import { RxResourceOptions } from '@angular/core/rxjs-interop'; interface SafeResourceRef { safeValue: Signal; resource: ResourceRef; } /** * Creates a {@link SafeResourceRef} that wraps an HTTP resource. * * * The purpose of this utility function is to prevent the resource from dropping the entire application * into an exception state when the resource.value() is read after it fails to load. * * If it does not have a value, it will return `undefined` (or the provided `defaultValue` if specified). */ declare function safeHttpResource(url: () => string | undefined, options?: HttpResourceOptions | undefined, defaultValue?: T): SafeResourceRef; /** * Creates a {@link SafeResourceRef} that wraps an RxJS resource. * * The purpose of this utility function is to prevent the resource from dropping the entire application * into an exception state when the resource.value() is read after it fails to load. * * If it does not have a value, it will return `undefined` (or the provided `defaultValue` if specified). */ declare function safeRxResource(options: RxResourceOptions, defaultValue?: T): SafeResourceRef; /** * Creates a {@link SafeResourceRef} that wraps an HTTP resource and preserves its previous value when it enters a loading state. * * The purpose of this utility function is to prevent the resource from dropping the entire application * into an exception state when the resource.value() is read after it fails to load, while also preserving the previous value during loading. * */ declare function staleHttpResource(url: () => string | undefined, options?: HttpResourceOptions | undefined, defaultValue?: T): SafeResourceRef; /** * Creates a {@link SafeResourceRef} that wraps an RxJS resource and preserves its previous value when it enters a loading state. * * The purpose of this utility function is to prevent the resource from dropping the entire application * into an exception state when the resource.value() is read after it fails to load, while also preserving the previous value during loading. * */ declare function staleRxResource(options: RxResourceOptions, defaultValue?: T): SafeResourceRef; /** * Creates a {@link SafeResourceRef} that wraps an HTTP resource and implements a * 'stale while revalidate' caching strategy * * This wrapper exhibits the following behaviors * * When the primary resource's `hasValue()` is false * - If the global cache service contains this resource's data, the cached data is immediately returned. * - If not in cache, the input `defaultValue` is returned (may be `undefined`) * * When the primary resource's `hasValue()` is true * Once the HTTP resource has data, the `safeValue` signal updates with * the new value. Any consumers of the `safeValue` computed() will receive fresh data. * A side effect updates the global cache with the fresh value */ declare function swrHttpResource(urlFn: () => string | undefined, options?: HttpResourceOptions | undefined, defaultValue?: T): SafeResourceRef; /** * Creates a {@link SafeResourceRef} that wraps an RxJS resource and implements a * 'stale while revalidate' caching strategy. * * An input cache key is required since data cannot be inferred from input parameters alone * * This wrapper exhibits the following behaviors * * When the primary resource's `hasValue()` is false * - If the global cache service contains this resource's data, the cached data is immediately returned. * - If not in cache, the input `defaultValue` is returned (may be `undefined`) * * When the primary resource's `hasValue()` is true * Once the RxJS resource has data, the `safeValue` signal updates with * the new value. Any consumers of the `safeValue` computed() will receive fresh data. * A side effect updates the global cache with the fresh value */ declare function swrRxResource(cacheKey: string, options: RxResourceOptions, defaultValue?: T): SafeResourceRef; export { safeHttpResource, safeRxResource, staleHttpResource, staleRxResource, swrHttpResource, swrRxResource }; export type { SafeResourceRef };