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

Use observers for callbacks #249

Merged
merged 8 commits into from
Aug 9, 2024
Merged

Use observers for callbacks #249

merged 8 commits into from
Aug 9, 2024

Conversation

janhohenheim
Copy link
Member

@janhohenheim janhohenheim commented Aug 9, 2024

  • This variant is probably closer to what will be upstreamed in Bevy, as Alice mentioned wanting to solve this using observers.
  • Its implementation is simpler (no need to learn about one-shot systems or SystemId, no need to be careful about memory leaks)
  • I removed the extra param from button.
    • With the current code, the user does not save on boilerplate when passing the callback to the function. But it incurs a bit of mental indirection that is not present when observe is called directly and it requires us to add some ugly generics to the button function. I like about the current code that it kinda teaches the user how to apply observers to entities for themselves.
    • Of course, this means a user can forget to handle the OnPress event as a consequence.

@janhohenheim janhohenheim requested a review from benfrankel August 9, 2024 16:46
docs/design.md Outdated Show resolved Hide resolved
docs/design.md Outdated Show resolved Hide resolved
docs/design.md Outdated Show resolved Hide resolved
docs/design.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@MiniaczQ MiniaczQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way better than what was here previously!

@janhohenheim janhohenheim requested a review from benfrankel August 9, 2024 17:47
docs/design.md Outdated Show resolved Hide resolved
docs/design.md Outdated Show resolved Hide resolved
@janhohenheim janhohenheim enabled auto-merge (squash) August 9, 2024 17:50
@janhohenheim janhohenheim merged commit 2f35840 into main Aug 9, 2024
4 checks passed
@janhohenheim janhohenheim deleted the observer-button branch August 9, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants