Closed
Conversation
james7132
approved these changes
May 7, 2022
Member
|
I updated #3863 (which as far as I know shouldn't have anything controversial) with the doc and type renamed from this PR. If you prefer to go with this one, you should also change in bevy_app: bevy/crates/bevy_app/src/app.rs Lines 623 to 625 in 743bd30 |
Member
Author
|
Closing in favor of #3863. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
EventWriter<T>are currently confusing to users: why does it matter if the underlying type is a resource?Tis never stored as a resource, instead,Events<T>is inserted as a resource.Resource, anyEvents<T>will beSend + Sync + 'staticif and only ifTis.EventorResourcenon-trivial, this coupling will be confusing and error-prone.Solution
Event: Send + Sync + 'statictrait, and use this in place ofResourcein the assorted event types.Eventso users do not need to manually implement or derive this trait (yet).Changelog
Events<T>,EventWriter<T>,EventReader<T>and so on now require that the underlying type isEvent, rather thanResource. Both of these are trivial supertraits ofSend + Sync + 'staticwith universal blanket implementations: this change is currently purely cosmetic.Context
This was first discussed in the context of the more controversial #2073.
You can see the confusion that this sort of conflation generates in #4680 (comment), where the changes made to the
Resourcetrait echo through to our event types in surprising ways.Down the line, there's an argument to be made for forcing a derive macro on both
ResourceandEvent, and supporting more configuration, but that's a conversation for another day.