8000 Snapshot should return a "View" Handle · Issue #79 · evaera/matter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.
This repository was archived by the owner on Jul 16, 2024. It is now read-only.
Snapshot should return a "View" Handle #79
Open
@Ukendio

Description

@Ukendio

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

For tracking
Partial implementation: #80

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0