3 unstable releases
Uses new Rust 2024
| 0.2.0 | Jan 14, 2026 |
|---|---|
| 0.1.1 | Oct 7, 2025 |
| 0.1.0 | Oct 7, 2025 |
#1692 in Game dev
Used in 5 crates
42KB
53 lines
bevy_channel_message
Send events via a channel from anywhere (eg. web-dom, c-ffi) to Bevy Observers.
Based on the original bevy_crossbeam_event but reverting to the buffered message system instead of migrating to observer/triggers as it did in 0.9.
usage
Add add events to your app using .add_channel_message::<EventType>:
#[derive(Message, Clone, Debug)]
struct LobbyJoined(Lobby);
impl Plugin for MyPlugin {
fn build(&self, app: &mut App) {
app.add_channel_message::<LobbyJoined>();
app.add_startup_system(setup);
app.add_system(handle_lobby_joined);
}
}
Fire events by using Res<ChannelMessageSender<EventType>> (which can be
cloned and sent into callbacks):
fn setup(service: Res<ThirdPartyCode>, sender: Res<ChannelMessageSender<LobbyJoined>>) {
let sender = sender.clone();
service.join_lobby(id, move |lobby| {
sender.send(LobbyJoined(lobby));
});
}
Handle the events just like normal Bevy events (which they are):
fn handle_lobby_joined(mut lobby_joined_events: MessageReader<LobbyJoined>) {
for lobby in lobby_joined_events.read() {
info!("lobby joined: {lobby:?}");
}
}
Our Other Crates
- bevy_channel_trigger
- bevy_debug_log
- bevy_device_lang
- bevy_web_popups
- bevy_libgdx_atlas
- bevy_ios_iap
- bevy_ios_review
- bevy_ios_gamecenter
- bevy_ios_alerts
- bevy_ios_notifications
- bevy_ios_impact
- bevy_ios_safearea
Compatible Bevy Versions
| bevy | our version |
|---|---|
| 0.18 | 0.2,main |
| 0.17 | 0.1 |
License
this crate is dual-licensed under either MIT or Apache 2.0, at your option.
Dependencies
~12MB
~219K SLoC