![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@vladnet/ecs
Advanced tools
Simple ecs implementation, inspired by Unity3d ECS.
npm install @vladnet/ecs
yarn add @vladnet/ecs
import { EntityManager, SystemManager } from "@vladnet/ecs";
Entities are managed by EntityManager
.
There are only two methods to work with entities, set
and unset
.
Set without id creates new entity, set with id updates existed one.
console.log(em.length); // 0
// create new entity
let myEntity = em.set({
name: "Petryk",
});
console.log(myEntity); // { id: "entity_1", name: "Petryk", }
console.log(em.length); // 1
// update existed one
myEntity = em.set({
id: newEntity.id,
name: "Vasylko",
});
console.log(myEntity); //{ id: "entity_1", name: "Vasylko", }
console.log(em.length); // 1
Just pass an entity id.
em.unset(myEntity.id);
EntityManager never mutates your data.
// create new entity
const newEntity = em.set({
name: "Petryk",
});
console.log(newEntity); // { id: "entity_1", name: "Petryk", }
// update existed one
const updatedEntity = em.set({
id: newEntity.id,
name: "Vasylko",
});
console.log(updatedEntity); //{ id: "entity_1", name: "Vasylko", }
console.log(newEntity === updatedEntity); // false
EntityManager has few methods working in the same way as such methofs in Array
:
forEach
, filter
, find
, some
, every
.
Sure thing, you can get plain array by em.toArray()
.
You could subscribe to set
or unset
events.
// on set
em.on(EEntityManagerEventTypes.set, (entity: IEntity) => {
// entity was set (new or updated)
}, context /* `this` for listener */);
// on unset
em.on(EEntityManagerEventTypes.unset, (entity: IEntity) => {
// entity was unset, do forget it and move forward
}, context /* `this` for listener */);
To manage you entities you should write a system.
System is just an object having update
method and optional start
method.
interface ISystem {
update: (em: EntityManager<IEntity>) => any;
start?: (em: EntityManager<IEntity>) => any;
}
const em = new EntityManager();
const sm = new SystemManager(em);
// add a system
const id = sm.add({
update(em) {
em
.filter(entity => entity.name === "Vasylko")
.forEach(entity => {
console.log(`Another one ${entity.name}!`);
});
}
});
// remove a system
sm.remove(id);
update
will be run each time entity manager changes (both set
or unset
actions). It will not run again for system own changes. SystemManager saves timestamp when its EntityManager and systems were updated.
start
will be run only once at SystemManager start.
Systems are asynchronous, means you could update EntityManager at anytime and all other systems will update.
// start all systems
sm.start();
// stop all systems
sm.stop();
FAQs
Entity Component System for Javascript. Inspired by Unity3D
The npm package @vladnet/ecs receives a total of 1 weekly downloads. As such, @vladnet/ecs popularity was classified as not popular.
We found that @vladnet/ecs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.