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 insert_state to App. #11043

Merged
merged 3 commits into from
Dec 21, 2023
Merged

Conversation

doonv
Copy link
Contributor

@doonv doonv commented Dec 20, 2023

Objective

Fix #10731.

Solution

Rename App::add_state<T>(&mut self) to init_state, and add App::insert_state<T>(&mut self, state: T). I decided on these names because they are more similar to init_resource and insert_resource.

I also removed the States trait's requirement for Default. Instead, init_state requires FromWorld.


Changelog

  • Renamed App::add_state to init_state.
  • Added App::insert_state.
  • Removed the States trait's requirement for Default.

Migration Guide

  • Renamed App::add_state to init_state.

@doonv doonv changed the title Add init insert state Add insert_state to App. Dec 20, 2023
@ItsDoot ItsDoot added C-Feature A new feature, making something new possible A-ECS Entities, components, systems, and events M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Dec 20, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Nice little API: I think this is nicer. More flexible, more consistent.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 21, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 21, 2023
Merged via the queue into bevyengine:main with commit ba0f8f9 Dec 21, 2023
23 checks passed
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 M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add app.add_state(inital_state) convenience method
4 participants