readEntityFrom()
Function
readEntityFrom<S, EntityType, IDType>(queryEntity:
QueryEntity
<S
,EntityType
,IDType
>, id:IDType
):Read
<EntityType
|undefined
>
Create a new Read by selecting an entity from a QueryEntity using its id:
const entity$: Read<EntityData | undefined> = readEntityFrom(queryEntity, entityId);
Source: akita-read/src/lib/read-entity-from.ts:20
Type parameters
Parameter | Default | Description |
---|---|---|
S extends EntityState <any , any > | - | entity state used by the queryEntity |
EntityType | getEntityType <S > | - |
IDType | getIDType <S > | - |
Parameters
Parameter | Type | Description |
---|---|---|
queryEntity | QueryEntity <S , EntityType , IDType > | QueryEntity to select from |
id | IDType | entity id to select |
Returns
Read
<EntityType
| undefined
>
Returns a new Read that emits the selected entity or undefined if the entity does not exist
readEntityFrom<S, K, EntityType, IDType>( queryEntity:
QueryEntity
<S
,EntityType
,IDType
>, id:IDType
, key:K
):Read
<EntityType
[K
] |undefined
>
Create a new Read by selecting an entity from a QueryEntity using its id and extracting the value using a given key:
const name$: Read<string | undefined> = readEntityFrom(queryEntity, entityId, 'name');
Source: akita-read/src/lib/read-entity-from.ts:41
Type parameters
Parameter | Default | Description |
---|---|---|
S extends EntityState <any , any > | - | entity state used by the queryEntity |
K extends string | number | symbol | - | key of the entity |
EntityType | getEntityType <S > | - |
IDType | getIDType <S > | - |
Parameters
Parameter | Type | Description |
---|---|---|
queryEntity | QueryEntity <S , EntityType , IDType > | QueryEntity to select from |
id | IDType | entity id to select |
key | K | key to extract from the entity |
Returns
Read
<EntityType
[K
] | undefined
>
Returns a new Read that emits extracted value of the selected entity or undefined if the entity does not exist
readEntityFrom<S, R, EntityType, IDType>( queryEntity:
QueryEntity
<S
,EntityType
,IDType
>, id:IDType
, projection:Function
):Read
<R
|undefined
>
Create a new Read by selecting an entity from a QueryEntity using its id and extracting the value using a given projection:
const name$: Read<string | undefined> = readEntityFrom(queryEntity, entityId, (entity) => entity.name);
Source: akita-read/src/lib/read-entity-from.ts:63
Type parameters
Parameter | Default | Description |
---|---|---|
S extends EntityState <any , any > | - | entity state used by the queryEntity |
R | - | returned type of the projection |
EntityType | getEntityType <S > | - |
IDType | getIDType <S > | - |
Parameters
Parameter | Type | Description |
---|---|---|
queryEntity | QueryEntity <S , EntityType , IDType > | QueryEntity to select from |
id | IDType | entity id to select |
projection | (entity?: EntityType ) => R | projection to pick from the entity |
Returns
Read
<R
| undefined
>
Returns a new Read that emits the result of the projection or undefined
if the entity does not exist