Code Monkey home page Code Monkey logo

Comments (4)

feiss avatar feiss commented on August 12, 2024

A naive and probably not very popular alternative --but much less verbose-- would be to merge all queries and events in the root of the system, and the user would be the one making sure that there's no name clashing. So, instead of:

this.queries.entities.forEach(entity => {})

this.events.entities.added.forEach(entity => {})
this.events.entities.removed.forEach(entity => {})
this.events.entities.changed.forEach(entity => {})
this.events.entities.rotatingChanged.forEach(entity => {})
this.events.entities.transformChanged.forEach(entity => {})

we would have:

this.entities.forEach(entity => {})

this.added.forEach(entity => {})
this.removed.forEach(entity => {})
this.changed.forEach(entity => {})
this.rotatingChanged.forEach(entity => {})
this.transformChanged.forEach(entity => {})

Example with two queries:

this.cars.forEach(entity => {})
this.bikes.forEach(entity => {})

this.bikeAdded.forEach(entity => {})
this.carAdded.forEach(entity => {})
this.bikeRotatingChanged.forEach(entity => {})
this.carTransformChanged.forEach(entity => {})
...

So it's a matter of naming, with much simpler syntax to remember. If you look at the examples, when you have only one query you call it 'entities', but as soon as you have more than one, you start putting significant names like "ball", "intersectingBall"..

from ecsy.

feiss avatar feiss commented on August 12, 2024

Another alternative, more cleaner but also not very verbose, would be adding an object for each query with all the events, and a list (or all, any other name) member for accessing the array of entities:

this.cars.list.forEach(entity => {})
this.bikes.list.forEach(entity => {})

this.bikes.added.forEach(entity => {})
this.cars.added.forEach(entity => {})
this.bikes.rotatingChanged.forEach(entity => {})
this.cars.ransformChanged.forEach(entity => {})

from ecsy.

joshmarinacci avatar joshmarinacci commented on August 12, 2024

from ecsy.

fernandojsg avatar fernandojsg commented on August 12, 2024

Closing this one in favor to https://github.com/fernandojsg/ecsy/issues/71 and https://github.com/fernandojsg/ecsy/pull/72

from ecsy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.