Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorthand for Singleton adding #184

Open
tynberry opened this issue Oct 8, 2024 · 5 comments
Open

Shorthand for Singleton adding #184

tynberry opened this issue Oct 8, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@tynberry
Copy link

tynberry commented Oct 8, 2024

When you want to add a singleton to query, you need to choose a term using term_at or filter using with and then say it is a singleton.

However it would be nice to have a simpler way to annotate singletons.

I propose two possible solutions, either add with_singleton and singleton that takes term index to merge the two calls or add Singleton<T> generic struct which can take a component to mark as singleton, similar to Option<T> marking as optional.

@Indra-db
Copy link
Owner

Indra-db commented Oct 15, 2024

@tynberry Singleton should be possible
with_singleton and singleton are out of the question. Sander, flecs itself, is opposed against those sort of small utility functions as it adds maintenance burden and I'd like to stick close enough to the CPP API as well.

also note there's the DSL macro exactly for this reason:

    system!(
        "processing_xxx_system",
        world,
        &mut ProcessingState ($), //singleton
        &AsyncTaskSender,
    )
    ```

@Indra-db
Copy link
Owner

@tynberry do you want to PR Singleton or should I add it to the backlog for myself?

@Indra-db Indra-db added enhancement New feature or request good first issue Good for newcomers labels Oct 15, 2024
@tynberry
Copy link
Author

I might look at it but you can keep it on backlog.

I know about the DSL macros, but from my experience of a low end computer user, rust analyzer does not work very well or at least as fast with them. I might look at them as well, but macros are still magic to me.

@Indra-db
Copy link
Owner

@tynberry yeah RA with macro's don't work great until the macro is somewhat finished.
Be sure to use the vs-code expand macro in case you're wondering what it produces

image

@Indra-db
Copy link
Owner

the DSL macro mostly follows the convention from here https://www.flecs.dev/flecs/md_docs_2FlecsQueryLanguage.html

but with some small differences (documented)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants