Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 436 Bytes

README.md

File metadata and controls

25 lines (18 loc) · 436 Bytes

Entity State

Simple but broad types for working with Entity State.

Installation

pnpm install -D @onsetsoftware/entity-state

Usage

import type { EntityState, HasId } from '@onsetsoftware/entity-state';

export function addEntity<TEntity extends HasId<TEntity>>(
  state: EntityState<TEntity>,
  entity: TEntity,
) {
  state.ids.push(entity.id);
  state.entities[entity.id] = entity;

  return state;
}