@spearwolf/shadow-objects
v0.30.2
Published
a reactive entity-component framework that feels at home in the shadows
Downloads
61
Readme
Shadow Objects
Shadow Objects is a reactive ECS (Entity Component System) library that decouples business logic from UI rendering. Entities are lightweight game objects; Shadow Objects are ECS components that attach behavior to them. Shadow environments can run on the main thread (local) or in a web worker (remote) -- both are first-class.
Installation
npm install @spearwolf/shadow-objectsQuick Example
import { Registry } from '@spearwolf/shadow-objects';
// Define a shadow object -- an ECS component with behavior
function MyComponent({ entity, useSignals }) {
const [count, setCount] = useSignals('count', 0);
entity.on('increment', () => setCount(count.get() + 1));
return () => {
// cleanup on destroy
};
}
// Register it: when a view node has the token 'my-component',
// this shadow object runs in the shadow environment
Registry.define('my-component', MyComponent);