Skip to content

Rename When system param to If#20325

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
CorvusPrudens:when-rename
Jul 29, 2025
Merged

Rename When system param to If#20325
alice-i-cecile merged 1 commit intobevyengine:mainfrom
CorvusPrudens:when-rename

Conversation

@CorvusPrudens
Copy link
Member

Objective

Regardless of where we land on #19489, When as a system param wrapper is a touch verbose. In many cases, users may find themselves liberally applying When to their fallible system params. I believe that If maintains the same semantics in a smaller and more readable package, and therefore should replace When.

Showcase

When:

fn fallible_params(player: When<Single<&mut Velocity, With<Player>>>, gravity: When<Res<Gravity>>) {}

If:

fn fallible_params(player: If<Single<&mut Velocity, With<Player>>>, gravity: If<Res<Gravity>>) {}

@janhohenheim janhohenheim added D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 29, 2025
@janhohenheim janhohenheim added this to the 0.17 milestone Jul 29, 2025
@jannik4
Copy link
Contributor

jannik4 commented Jul 29, 2025

This is also more in line with run_if, which basically does the same (controlling if a system runs/is skipped).

@janhohenheim janhohenheim 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 Jul 29, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jul 29, 2025
Merged via the queue into bevyengine:main with commit 4b51c21 Jul 29, 2025
41 checks passed
tychedelia pushed a commit to tychedelia/bevy that referenced this pull request Jul 31, 2025
# Objective

Regardless of where we land on bevyengine#19489, `When` as a system param wrapper
is a touch verbose. In many cases, users may find themselves liberally
applying `When` to their fallible system params. I believe that `If`
maintains the same semantics in a smaller and more readable package, and
therefore should replace `When`.

## Showcase

`When`:
```rs
fn fallible_params(player: When<Single<&mut Velocity, With<Player>>>, gravity: When<Res<Gravity>>) {}
```

`If`:
```rs
fn fallible_params(player: If<Single<&mut Velocity, With<Player>>>, gravity: If<Res<Gravity>>) {}
```
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 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants