[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/core/Resource [Back]  [Original]

Resource Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/core

Resource

interface
stablesince v22.0

A Resource is an asynchronous dependency (for example, the results of an API call) that is managed and delivered through signals.

On this page

    arrow_upward_alt Back to the top

    API

        
          interface Resource<T> {  readonly value: Signal<T>;  readonly status: Signal<ResourceStatus>;  readonly error: Signal<Error | undefined>;  readonly isLoading: Signal<boolean>;  readonly snapshot: Signal<ResourceSnapshot<T>>;
    hasValue(this: T extends undefined ? this : never): this is Resource<Exclude<T, undefined>>; hasValue(): boolean;
    }

    value

    Signal<T>

    The current value of the Resource, or throws an error if the resource is in an error state.

    status

    Signal<ResourceStatus>

    The current status of the Resource, which describes what the resource is currently doing and what can be expected of its value.

    error

    Signal<Error | undefined>

    When in the error state, this returns the last known error from the Resource.

    isLoading

    Signal<boolean>

    Whether this resource is loading a new value (or reloading the existing one).

    snapshot

    Signal<ResourceSnapshot<T>>

    The current state of this resource, represented as a ResourceSnapshot.

    hasValue

    2 overloads

    Whether this resource has a valid current value.

    This function is reactive.

    @paramthisT extends undefined ? this : never
    @returnsthis is Resource<Exclude<T, undefined>>
    @returnsboolean

    Description

    A Resource is an asynchronous dependency (for example, the results of an API call) that is managed and delivered through signals.

    The usual way of creating a Resource is through the resource function, but various other APIs may present Resource instances to describe their own concepts.

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page