You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
queryResult:snapshot() performs all of the iterator task at once and provides you the results of the query at the moment it is called. Hecs has a similar feature with query().views(), which is meant for repeated random access. It provides you a handle to discern whether it contains a specific entity and to access its data easily at an amortized cost via Views.get() and Views.contains() respectively.
I think providing similar methods will make :snapshot a more meaningful arm to QueryResult. We could even naively implement this by changing the list into a dictionary that maps the entity id to its packed data, and returning it, allowing people to just index it. But this wouldn't preserve the same order of traversal of entities as the query.
Considerations
This is a breaking change as it would most likely change the return type. Alternatively we can look to make a separate method called view.
Side note
Currently, you can't follow the :without() arm with :snapshot(). We may want to make a separate change to address this. #85
But I think we should extend the API rather than change it. I think adding a view method would be better. Bevy has a lot of thought into these aspects of usage. Since future changes we may want to make down the road and/or as roblox makes things possible will be affected by the API we make now. What I definitely don't want to do at this moment is break people's current use of snapshot. We're allowed to break things like that in v0, but I don't see a good reason to with this. There's no reason the current snapshot is bad. It just doesn't do these other things we also want.
queryResult:snapshot()
performs all of the iterator task at once and provides you the results of the query at the moment it is called. Hecs has a similar feature withquery().views()
, which is meant for repeated random access. It provides you a handle to discern whether it contains a specific entity and to access its data easily at an amortized cost viaViews.get()
andViews.contains()
respectively.I think providing similar methods will make
:snapshot
a more meaningful arm toQueryResult
. We could even naively implement this by changing the list into a dictionary that maps the entity id to its packed data, and returning it, allowing people to just index it. But this wouldn't preserve the same order of traversal of entities as the query.Considerations
This is a breaking change as it would most likely change the return type. Alternatively we can look to make a separate method called view.
Side note
Currently, you can't follow the
:without()
arm with:snapshot()
. We may want to make a separate change to address this. #85For tracking
Partial implementation: #80
The text was updated successfully, but these errors were encountered: