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

add_observer(s) should accept a tuple of observers akin to add_systems or add_systems should allow for observers #17190

Open
BobG1983 opened this issue Jan 6, 2025 · 1 comment
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Design This issue requires design work to think about how it would best be accomplished

Comments

@BobG1983
Copy link
Contributor

BobG1983 commented Jan 6, 2025

What problem does this solve or what need does it fill?

Right now, if you are adding multiple observer "systems" to an app, you must call add_observer for each such "system". This has pretty poor ergonomics IMO.

app.add_systems(FixedUpdate, (system_a, system_b, system_c)).add_observer(observer_a).add_observer(observer_b).add_observer(observer_c)

What solution would you like?

Either:

app.add_systems(FixedUpdate, (system_a, system_b, system_c)).add_observers((observer_a, observer_b, observer_c))

or:

app.add_systems(FixedUpdate, (system_a, system_b, system_c, observer_a, observer_b, observer_c))

I think I'd likely prefer the latter, though it's less specific, because I could, ostensibly, then also add run_conditions etc to my observers (run if in state, etc).

What alternative(s) have you considered?

Truthfully, none.

@BobG1983 BobG1983 added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jan 6, 2025
@BobG1983
Copy link
Contributor Author

BobG1983 commented Jan 6, 2025

As a related aside, it's unclear to be when it is best to use Observers vs Events or vice versa (I'm currently mostly using observers for change detection).

@BenjaminBrienen BenjaminBrienen added A-ECS Entities, components, systems, and events S-Needs-Design This issue requires design work to think about how it would best be accomplished D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Triage This issue needs to be labelled labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Design This issue requires design work to think about how it would best be accomplished
Projects
None yet
Development

No branches or pull requests

2 participants