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

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

WritableResource

interface
stablesince v22.0

A Resource with a mutable value.

On this page

    arrow_upward_alt Back to the top

    API

        
          interface WritableResource<T> extends Resource<T> {  readonly value: WritableSignal<T>;
    hasValue(this: T extends undefined ? this : never): this is WritableResource<Exclude<T, undefined>>; hasValue(): boolean;
    set(value: T): void; update(updater: (value: T) => T): void; asReadonly(): Resource<T>; reload(): boolean; readonly override status: Signal<ResourceStatus>; readonly override error: Signal<Error | undefined>; readonly override isLoading: Signal<boolean>; readonly override snapshot: Signal<ResourceSnapshot<T>>;}

    hasValue

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

    set

    void

    Convenience wrapper for value.set.

    @paramvalueT
    @returnsvoid

    update

    void

    Convenience wrapper for value.update.

    @paramupdater(value: T) => T
    @returnsvoid

    reload

    boolean

    Instructs the resource to re-load any asynchronous dependency it may have.

    Note that the resource will not enter its reloading state until the actual backend request is made.

    @returnsboolean

    true if a reload was initiated, false if a reload was unnecessary or unsupported

    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.

    Description

    A Resource with a mutable value.

    Overwriting the value of a resource sets it to the 'local' state.

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page