-
Notifications
You must be signed in to change notification settings - Fork 115
Syntax for queries and events #70
Comments
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".. |
Another alternative, more cleaner but also not very verbose, would be adding an object for each query with all the events, and a 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 => {}) |
I like this one
Sent from planet Earth
… On Sep 9, 2019, at 4:00 AM, Diego F. Goberna ***@***.***> wrote:
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 => {})
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Closing this one in favor to https://github.com/fernandojsg/ecsy/issues/71 and https://github.com/fernandojsg/ecsy/pull/72 |
Currently the syntax for queries and its events is the following:
I'd like to get feedback on using a common path
this.queries.entities.*
for both type of queries. Something like:The text was updated successfully, but these errors were encountered: