You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
365 B
10 lines
365 B
import { AppState, Entity, EntityTypes } from '../types'
|
|
|
|
export const getEntityStore = (state: AppState) => state.entities
|
|
|
|
export const getEntity = <T extends Entity = Entity>(state: AppState, type: EntityTypes, id: string) => {
|
|
const store = getEntityStore(state)
|
|
const collection = store[type]
|
|
|
|
return collection ? collection[id] as T : undefined
|
|
}
|