Skip to content

Commit be46db6

Browse files
committed
chore: add release notes
1 parent a664905 commit be46db6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Observer Run Conditions
3+
authors: ["@jonas-meyer"]
4+
pull_requests: [22602]
5+
---
6+
7+
Observers can now use run conditions with `.run_if()`, the same pattern systems use for conditional execution.
8+
9+
```rust
10+
#[derive(Resource)]
11+
struct GamePaused(bool);
12+
13+
// Observer only runs when game is not paused
14+
app.add_observer(
15+
on_damage.run_if(|paused: Res<GamePaused>| !paused.0)
16+
);
17+
18+
// Multiple conditions can be chained (AND semantics)
19+
app.add_observer(
20+
on_damage
21+
.run_if(|paused: Res<GamePaused>| !paused.0)
22+
.run_if(resource_exists::<Player>)
23+
);
24+
```
25+
26+
This works with `add_observer`, entity `.observe()`, and the `Observer` builder pattern.

0 commit comments

Comments
 (0)