Skip to content

Add Commands::run_schedule#16537

Merged
mockersf merged 2 commits intobevyengine:mainfrom
bushrat011899:RunScheduleCommand
Dec 2, 2024
Merged

Add Commands::run_schedule#16537
mockersf merged 2 commits intobevyengine:mainfrom
bushrat011899:RunScheduleCommand

Conversation

@bushrat011899
Copy link
Copy Markdown
Contributor

@bushrat011899 bushrat011899 commented Nov 28, 2024

Objective

Solution

  • Added Commands::run_schedule, which internally calls World::try_run_schedule, panicking on any issues.

Testing

  • Added doctest
  • Ran CI

Showcase

Instead of writing:

commands.queue(|world: &mut World| world.run_schedule(FooSchedule));

You can now write:

commands.run_schedule(FooSchedule);

Convenience method wrapping `World::try_run_schedule`
@bushrat011899 bushrat011899 added C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 28, 2024
@bushrat011899 bushrat011899 added this to the 0.16 milestone Nov 28, 2024
Copy link
Copy Markdown
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.

Not just unwrapping I see :P I think this is good default behavior, but we'll need to come back and change this when we tackle command error handling.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 28, 2024
@bushrat011899
Copy link
Copy Markdown
Contributor Author

Not just unwrapping I see :P I think this is good default behavior, but we'll need to come back and change this when we tackle command error handling.

I was half tempted to do // TODO: commands need a coherent error handling policy but I thought I'd just sneak in my preferred solution!

Copy link
Copy Markdown
Member

@mockersf mockersf left a comment

Choose a reason for hiding this comment

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

I would prefer this to panic until there's a way to react in code to errors

Running a schedule that doesn't exist doesn't seem like something that should be ignored and you would still expect everything working

@BenjaminBrienen
Copy link
Copy Markdown
Contributor

Does error! not set the right expectation?

@mockersf
Copy link
Copy Markdown
Member

mockersf commented Dec 1, 2024

no, you can't react to it in code

@alice-i-cecile
Copy link
Copy Markdown
Member

Yeah we can swap to panicking for now for consistency and then fix it during command error handling.

@mockersf mockersf added this pull request to the merge queue Dec 2, 2024
Merged via the queue into bevyengine:main with commit c02696b Dec 2, 2024
ecoskey pushed a commit to ecoskey/bevy that referenced this pull request Jan 6, 2025
# Objective

- Fixes bevyengine#16495

## Solution

- Added `Commands::run_schedule`, which internally calls
`World::try_run_schedule`, logging any issues.

## Testing

- Added doctest
- Ran CI

## Showcase

Instead of writing:

```rust
commands.queue(|world: &mut World| world.run_schedule(FooSchedule));
```

You can now write:

```rust
commands.run_schedule(FooSchedule);
```
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-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Commands::run_schedule

4 participants