Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .claude/commands/create-pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
allowed-tools: Bash(git:*),
description: Create PR
---

Please create a PR.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev pkg-config
if: runner.os == 'linux'
- name: Build & run tests
env:
RUSTFLAGS: "-C debuginfo=0"
CARGO_BUILD_JOBS: "1"
run: |
cargo test -F state,audio,tokio,record,side-effect
- name: Run tests with all features
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

### Features
- Support for Bevy 0.17.0
- Added `once::message` module with `write()`, `write_default()`, and `app_exit_success()` actions
- Added `wait::message` module with `comes()`, `comes_and()`, `read()`, and `read_and()` actions

### Deprecations
- Deprecated `once::event` module in favor of `once::message` (Event trait replaced with Message in Bevy 0.17)
- Deprecated `wait::event` module in favor of `wait::message` (Event trait replaced with Message in Bevy 0.17)

### Improvements
- Updated all examples, documentation, and tests to use the new `message` API
- Deprecated functions now delegate to their `message` equivalents for consistency

## v0.12.0
[Release note](https://github.com/not-elm/bevy_flurx/releases/tag/v0.12.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn spawn_reactor(mut commands: Commands) {
assert_eq!(message, "count is 4");

info!("Done!");
task.will(Update, once::event::app_exit_success()).await;
task.will(Update, once::message::app_exit_success()).await;
}));
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/actions/delay.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Delay for 1 second, then send an event
task.will(Update, delay::time().with(Duration::from_secs(1))
.then(once::event::app_exit_success())
.then(once::message::app_exit_success())
).await;
}));
}
Expand Down
8 changes: 4 additions & 4 deletions docs/src/actions/inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Hp(u8);
fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Use inspect to log damage without affecting the main flow
task.will(Update, wait::event::read::<Damage>()
task.will(Update, wait::message::read::<Damage>()
.pipe(inspect(once::run(|In(Damage(damage)): In<Damage>| {
println!("Players take {damage} points of damage.");
})))
Expand Down Expand Up @@ -57,7 +57,7 @@ struct Hp(u8);
fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Use the inspect method for a more concise syntax
task.will(Update, wait::event::read::<Damage>()
task.will(Update, wait::message::read::<Damage>()
.inspect(once::run(|In(Damage(damage)): In<Damage>| {
println!("Players take {damage} points of damage.");
}))
Expand Down Expand Up @@ -134,7 +134,7 @@ struct Damage(u8);
fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Collect metrics while processing events
task.will(Update, wait::event::read::<Damage>()
task.will(Update, wait::message::read::<Damage>()
.inspect(once::run(|In(Damage(damage)): In<Damage>, mut metrics: ResMut<Metrics>| {
metrics.damage_dealt += damage as u32;
println!("Total damage dealt: {}", metrics.damage_dealt);
Expand Down Expand Up @@ -173,7 +173,7 @@ enum ActionType {
fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Perform conditional side effects based on input values
task.will(Update, wait::event::read::<PlayerAction>()
task.will(Update, wait::message::read::<PlayerAction>()
.inspect(once::run(|In(action): In<PlayerAction>| {
match action.action_type {
ActionType::Attack => println!("Player attacks for {} damage!", action.value),
Expand Down
24 changes: 14 additions & 10 deletions docs/src/actions/once/event.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# once::event

The `once::event` module provides actions for sending Bevy events exactly once. These actions are specialized versions of `once::run` that focus specifically on event sending operations.
> **⚠️ DEPRECATED**: This module is deprecated since Bevy 0.17. Please use [`once::message`](./message.md) instead. The `Event` trait has been replaced with `Message` in Bevy 0.17.

The `once::event` module provides actions for sending Bevy messages exactly once. These actions are specialized versions of `once::run` that focus specifically on message sending operations.

## Functions

Expand All @@ -20,14 +22,14 @@ use bevy::prelude::*;
use bevy_flurx::prelude::*;

Reactor::schedule(|task| async move {
task.will(Update, once::event::send().with(AppExit::Success)).await;
task.will(Update, once::message::write().with(AppExit::Success)).await;
});
```

### send_default

```rust
once::event::send_default<E>() -> ActionSeed
once::message::write_default<E>() -> ActionSeed
```

Creates an action that sends a default-constructed event once. The event type must implement the `Default` trait.
Expand All @@ -40,14 +42,14 @@ use bevy::prelude::*;
use bevy_flurx::prelude::*;

Reactor::schedule(|task| async move {
task.will(Update, once::event::send_default::<AppExit>()).await;
task.will(Update, once::message::write_default::<AppExit>()).await;
});
```

### app_exit_success

```rust
once::event::app_exit_success() -> Action<AppExit, ()>
once::message::app_exit_success() -> Action<AppExit, ()>
```

A convenience function that creates an action to send the `AppExit::Success` event once, which will exit the application successfully.
Expand All @@ -59,15 +61,17 @@ use bevy::prelude::*;
use bevy_flurx::prelude::*;

Reactor::schedule(|task| async move {
task.will(Update, once::event::app_exit_success()).await;
task.will(Update, once::message::app_exit_success()).await;
});
```

## When to Use

Use `once::event` actions when you need to:
- Send a specific event exactly once
- Send a default-constructed event exactly once
> **Note**: This module is deprecated. Use `once::message` instead.

Use `once::message` actions when you need to:
- Send a specific message exactly once
- Send a default-constructed message exactly once
- Exit the application with a success status

For more complex event handling or when you need to access other system parameters, consider using the more general `once::run` action.
For more complex message handling or when you need to access other system parameters, consider using the more general `once::run` action.
2 changes: 1 addition & 1 deletion docs/src/actions/pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Wait for a PlayerHit event and then process it
task.will(Update,
wait::event::read::<PlayerHit>()
wait::message::read::<PlayerHit>()
.pipe(once::run(|In(PlayerHit(entity)): In<PlayerHit>, mut players: Query<&mut Hp>| {
players.get_mut(entity).unwrap().0 -= 10;
println!("Player hit! HP reduced to {}", players.get(entity).unwrap().0);
Expand Down
6 changes: 3 additions & 3 deletions docs/src/actions/through.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct Damage(usize);
fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Use through to insert a delay without affecting the data flow
task.will(Update, wait::event::read::<Damage>()
task.will(Update, wait::message::read::<Damage>()
.pipe(through(delay::time().with(Duration::from_millis(500))))
.pipe(once::run(|In(Damage(damage)): In<Damage>| {
println!("Player takes {damage} points of damage.");
Expand All @@ -49,7 +49,7 @@ struct Damage(usize);
fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Use the through method for a more concise syntax
task.will(Update, wait::event::read::<Damage>()
task.will(Update, wait::message::read::<Damage>()
.through(delay::time().with(Duration::from_millis(500)))
.pipe(once::run(|In(Damage(damage)): In<Damage>| {
println!("Player takes {damage} points of damage.");
Expand Down Expand Up @@ -139,7 +139,7 @@ fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
// Create a complex action flow with through
task.will(Update,
wait::event::read::<PlayerAction>()
wait::message::read::<PlayerAction>()
.through(once::run(|In(action): In<PlayerAction>| {
println!("Received action: {} with value {}", action.action_type, action.value);
}))
Expand Down
4 changes: 2 additions & 2 deletions docs/src/actions/wait/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ struct Event2;
Reactor::schedule(|task| async move {
// Wait for both events and get their values
let (event1, event2) = task.will(Update, wait_all![
wait::event::read::<Event1>(),
wait::event::read::<Event2>()
wait::message::read::<Event1>(),
wait::message::read::<Event2>()
]).await;

// This code runs after both events are received
Expand Down
2 changes: 1 addition & 1 deletion docs/src/actions/wait/any.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Reactor::schedule(|task| async move {
// Wait until either the B key is pressed or an AppExit event is received
let index = task.will(Update, wait::any().with(actions![
wait::input::just_pressed().with(KeyCode::KeyB),
wait::event::comes::<AppExit>()
wait::message::comes::<AppExit>()
])).await;

// Check which action completed
Expand Down
2 changes: 1 addition & 1 deletion docs/src/actions/wait/both.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Reactor::schedule(|task| async move {
// Wait for both the R key to be pressed and an AppExit event to be received
let (_, exit_event) = task.will(Update, wait::both(
wait::input::just_pressed().with(KeyCode::KeyR),
wait::event::read::<AppExit>()
wait::message::read::<AppExit>()
)).await;

// This code runs after both conditions are met
Expand Down
2 changes: 1 addition & 1 deletion docs/src/actions/wait/either.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Reactor::schedule(|task| async move {
// Wait until either a system returns false or an AppExit event is received
let result = task.will(Update, wait::either(
wait::until(|| false),
wait::event::read::<AppExit>()
wait::message::read::<AppExit>()
)).await;

match result {
Expand Down
34 changes: 19 additions & 15 deletions docs/src/actions/wait/event.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# wait::event

The `wait::event` module provides actions for waiting to receive Bevy events. These actions are useful for creating tasks that respond to events in your game or application.
> **⚠️ DEPRECATED**: This module is deprecated since Bevy 0.17. Please use [`wait::message`](./message.md) instead. The `Event` trait has been replaced with `Message` in Bevy 0.17.

The `wait::event` module provides actions for waiting to receive Bevy messages. These actions are useful for creating tasks that respond to messages in your game or application.

## Functions

### comes

```
wait::event::comes<E>() -> ActionSeed
wait::message::comes<E>() -> ActionSeed
```

Creates an action that waits until an event of type `E` is received. The action completes when the event is received but does not return the event itself.
Expand All @@ -21,7 +23,7 @@ use bevy_flurx::prelude::*;

Reactor::schedule(|task| async move {
// Wait for an AppExit event
task.will(Update, wait::event::comes::<AppExit>()).await;
task.will(Update, wait::message::comes::<AppExit>()).await;

// This code runs after an AppExit event is received
println!("App is exiting!");
Expand All @@ -31,7 +33,7 @@ Reactor::schedule(|task| async move {
### comes_and

```
wait::event::comes_and<E>(predicate: impl Fn(&E) -> bool + Send + Sync + 'static) -> ActionSeed
wait::message::comes_and<E>(predicate: impl Fn(&E) -> bool + Send + Sync + 'static) -> ActionSeed
```

Creates an action that waits until an event of type `E` is received and the event matches the given predicate. The action completes when a matching event is received but does not return the event itself.
Expand All @@ -45,7 +47,7 @@ use bevy_flurx::prelude::*;

Reactor::schedule(|task| async move {
// Wait for a successful AppExit event
task.will(Update, wait::event::comes_and::<AppExit>(|e| {
task.will(Update, wait::message::comes_and::<AppExit>(|e| {
e.is_success()
})).await;

Expand All @@ -57,7 +59,7 @@ Reactor::schedule(|task| async move {
### read

```
wait::event::read<E>() -> ActionSeed<(), E>
wait::message::read<E>() -> ActionSeed<(), E>
```

Creates an action that waits until an event of type `E` is received and returns a clone of the event. This is similar to `comes`, but it returns the event itself.
Expand All @@ -71,7 +73,7 @@ use bevy_flurx::prelude::*;

Reactor::schedule(|task| async move {
// Wait for an AppExit event and get the event
let exit_event = task.will(Update, wait::event::read::<AppExit>()).await;
let exit_event = task.will(Update, wait::message::read::<AppExit>()).await;

// This code runs after an AppExit event is received
println!("App is exiting with status: {:?}", exit_event);
Expand All @@ -81,7 +83,7 @@ Reactor::schedule(|task| async move {
### read_and

```rust
wait::event::read_and<E>(predicate: impl Fn(&E) -> bool + Send + Sync + 'static) -> ActionSeed<(), E>
wait::message::read_and<E>(predicate: impl Fn(&E) -> bool + Send + Sync + 'static) -> ActionSeed<(), E>
```

Creates an action that waits until an event of type `E` is received, the event matches the given predicate, and returns a clone of the event. This is similar to `comes_and`, but it returns the event itself.
Expand All @@ -95,7 +97,7 @@ use bevy_flurx::prelude::*;

Reactor::schedule(|task| async move {
// Wait for a successful AppExit event and get the event
let exit_event = task.will(Update, wait::event::read_and::<AppExit>(|e| {
let exit_event = task.will(Update, wait::message::read_and::<AppExit>(|e| {
e.is_success()
})).await;

Expand All @@ -106,10 +108,12 @@ Reactor::schedule(|task| async move {

## When to Use

Use `wait::event` actions when you need to:
- Wait for specific events to occur before continuing execution
- React to events in an asynchronous manner
- Filter events based on their content using predicates
- Retrieve event data for further processing
> **Note**: This module is deprecated. Use `wait::message` instead.

Use `wait::message` actions when you need to:
- Wait for specific messages to occur before continuing execution
- React to messages in an asynchronous manner
- Filter messages based on their content using predicates
- Retrieve message data for further processing

For more complex event handling scenarios, consider combining `wait::event` with other wait actions like `wait::either` or `wait::any` to wait for multiple different event types.
For more complex message handling scenarios, consider combining `wait::message` with other wait actions like `wait::either` or `wait::any` to wait for multiple different message types.
2 changes: 1 addition & 1 deletion examples/custom_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn spawn_reactor(mut commands: Commands) {
delay: Duration::from_secs(3),
message: "After 3 seconds, this message is displayed.",
}))
.then(once::event::app_exit_success())
.then(once::message::app_exit_success())
})
.await;
}));
Expand Down
2 changes: 1 addition & 1 deletion examples/cut_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn spawn_reactor(mut commands: Commands) {
.then(once::switch::off::<MoveSlowly>())
.then(once::switch::on::<MoveFast>())
.then(delay::time().with(Duration::from_millis(300)))
.then(once::event::app_exit_success())
.then(once::message::app_exit_success())
})
.await;
}));
Expand Down
4 changes: 2 additions & 2 deletions examples/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct Damage(usize);
fn spawn_reactor(mut commands: Commands) {
commands.spawn(Reactor::schedule(|task| async move {
task.will(Update, {
wait::event::read::<Damage>()
wait::message::read::<Damage>()
.inspect(once::run(|In(damage): In<Damage>| {
info!("Hit damage: {}", damage.0);
}))
Expand All @@ -40,7 +40,7 @@ fn spawn_reactor(mut commands: Commands) {
info!("Player HP: {}", player_hp.0);
},
))
.then(once::event::app_exit_success())
.then(once::message::app_exit_success())
})
.await;
}));
Expand Down
2 changes: 1 addition & 1 deletion examples/side_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn spawn_reactor(mut commands: Commands) {
.await;

info!("Done!");
task.will(Update, once::event::app_exit_success()).await;
task.will(Update, once::message::app_exit_success()).await;
}));
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ fn spawn_reactor(mut commands: Commands) {
assert_eq!(message, "count is 4");

info!("Done!");
task.will(Update, once::event::app_exit_success()).await;
task.will(Update, once::message::app_exit_success()).await;
}));
}
2 changes: 1 addition & 1 deletion src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ where
/// let actions: [ActionSeed; 3] = actions![
/// once::run(||{}),
/// delay::frames().with(3),
/// wait::event::comes::<AppExit>()
/// wait::message::comes::<AppExit>()
/// ];
/// ```
#[macro_export]
Expand Down
Loading