| Crates.io | bevy_channel_message |
| lib.rs | bevy_channel_message |
| version | 0.2.0 |
| created_at | 2025-10-07 21:19:42.136037+00 |
| updated_at | 2026-01-14 17:42:35.695343+00 |
| description | Send events via a channels form anywhere (eg. c-ffi) to Bevy (buffered) messages. |
| homepage | |
| repository | https://github.com/rustunit/bevy_channel_message |
| max_upload_size | |
| id | 1872841 |
| size | 156,772 |
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.
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:?}");
}
}
| bevy | our version |
|---|---|
| 0.18 | 0.2,main |
| 0.17 | 0.1 |
this crate is dual-licensed under either MIT or Apache 2.0, at your option.