Constructs a Resource
that projects a reactive request to an asynchronous operation defined by
a loader function, which exposes the result of the loading operation via signals.
API
Description
function resource<T, R>( options: ResourceOptions<T, R>): ResourceRef<T>;
resource
ResourceRef<T>
Constructs a Resource
that projects a reactive request to an asynchronous operation defined by
a loader function, which exposes the result of the loading operation via signals.
Note that resource
is intended for read operations, not operations which perform mutations.
resource
will cancel in-progress loads via the AbortSignal
when destroyed or when a new
request object becomes available, which could prematurely abort mutations.
@returns
ResourceRef<T>
Jump to details