Function: mapToResource()
mapToResource<
Name
,Store
>(store
,name
):MappedResource
<Store
,Name
>
Defined in: libs/ngrx-toolkit/src/lib/with-resource.ts:302
Experimental
Type Parameters
• Name extends string
| number
| symbol
• Store extends Record
<string
, unknown
>
Parameters
store
Store
The store instance to map the resource to.
name
Name
The name of the resource to map.
Returns
MappedResource
<Store
, Name
>
ResourceRef<T>
Description
Maps a named resource to type Resource<T>
.
Usage Notes
const store = signalStore(
withState({ userId: undefined as number | undefined }),
withResource(({ userId }) => ({
user: httpResource<User[]>(() => '/users', { defaultValue: [] }),
}))
);
const userResource = mapToResource(store, 'user');
userResource satisfies Resource<User[]>;