Skip to Content

Entities

Entities are stateful objects that participate in the simulation. They have a unique id and a generic state.

Adding Entities

ctx.addEntity({ id: 'server-1', state: { busy: false, processed: 0 } });

Accessing Entities

const server = ctx.getEntity<{ busy: boolean; processed: number }>('server-1'); server!.state.busy = true;

Removing Entities

ctx.removeEntity('server-1');

Listing All Entities

const allEntities = ctx.getAllEntities();

Design

Entities are minimal by design. The framework does not enforce any schema on entity state — that is your domain. Users define their own state shape via the generic parameter.

Immutability recommendation: Treat event.payload as readonly. TypeScript’s Readonly<T> can be used in the TEventMap generic for enforcement.

Last updated on