
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@latticexyz/recs
Advanced tools
`recs` is built with reactivity in mind. `Components` and `Queries` expose an `update$` stream, that `Systems` can react to.
recs
is built with reactivity in mind.
Components
and Queries
expose an update$
stream, that Systems
can react to.
To build some fundamental intuition about ECS, have a look at our MUD ECS introduction.
recs
is seamlessly integrated with the other MUD libraries, but can be used independently.
For detailed documentation, check out mud.dev/recs.
import {
createWorld,
defineComponent,
createEntity,
withValue,
defineSystem,
Has,
getComponentValue,
setComponent,
} from "@latticexyz/recs";
// Create a new World
const World = createWorld();
// Define a couple components
const Position = defineComponent(world, { x: Type.Number, y: Type.Number });
const Movable = defineComponent(world, { speed: Type.Number });
// Create a new entity
const entity1 = createEntity(world, [withValue(Position, { x: 0, y: 0 }), withValue(Movable, { speed: 10 })]);
// Define a system that reacts to updates of movable entities with a position
defineSystem(world, [Has(Position), Has(Movable)], (update) => {
console.log("Entity", update.entity, "moved to", update.value);
// ... do stuff, like rendering the entity on the screen, etc
});
// Move the entity around
setInterval(() => {
const currentPosition = getComponentValue(Position, entity1);
const newPosition = { x: position.x + 1, y: position.y + 1 };
setComponent(Position, entity1, newPosition);
}, 1000);
FAQs
`recs` is built with reactivity in mind. `Components` and `Queries` expose an `update$` stream, that `Systems` can react to.
The npm package @latticexyz/recs receives a total of 1,689 weekly downloads. As such, @latticexyz/recs popularity was classified as popular.
We found that @latticexyz/recs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.