[Merged by Bors] - Add helpers to send Events from World#5355
[Merged by Bors] - Add helpers to send Events from World#5355aevyrie wants to merge 9 commits intobevyengine:mainfrom
Events from World#5355Conversation
WorldEvents from World
|
|
|
Previously attempted in #3839. |
Nilirad
left a comment
There was a problem hiding this comment.
I have mixed feelings about using the noun-verb grammar, but I wouldn't block that.
I would have suggested you to link to EventWriter examples, but there are none. 😐
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
2a57b6a to
e4b489c
Compare
mockersf
left a comment
There was a problem hiding this comment.
Could you also add the send_batch method to have the same features that the EventWriter?
Nilirad
left a comment
There was a problem hiding this comment.
I prefer to write “Event” in monospace since we're linking to the trait itself and we're passing a type that implements it as an argument.
I'm OK for now to link to the trait instead of the module in the docs, since there is practically no documentation at the module level. This can be changed later with an event docs overhaul.
I prefer that the suggestion made in this comment should be applied before merging.
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
|
Added |
|
bors r+ |
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
|
Pull request successfully merged into main. Build succeeded: |
Events from WorldEvents from World
|
missed to propose a rename before this was merged: #5383 |
after #5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
…5383) after bevyengine#5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
…5383) after bevyengine#5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
…5383) after bevyengine#5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective Use the `World::send_event` method added in #5355 to simplify a doc example for `EventWriter`.
Objective
World, it's not obvious how to send an event.Commandthat needs to send anEvent.Eventsare a first-class construct in bevy, even though they are justResourcesunder the hood. Their methods should be discoverable.Solution
Res<Events<T>>.Changelog