#crossbeam-channel #bevy

bevy_crossbeam_event

Fire Bevy events from crossbeam channels

8 breaking releases

Uses new Rust 2024

0.10.0 Jan 17, 2026
0.9.0 Oct 2, 2025
0.8.0 Apr 25, 2025
0.7.0 Nov 30, 2024
0.1.0 Mar 10, 2023

#1915 in Game dev


Used in 2 crates

MIT/Apache

17KB
55 lines

bevy_crossbeam_event

crates.io MIT/Apache 2.0 crates.io docs.rs

Fire Bevy events from crossbeam channels.

Useful if you need to handle callbacks in 3rd party libraries etc. like steamworks-rs, or getting events out of tracing layers.

Usage

Add add events to your app using .add_crossbeam_event::<EventType>:

#[derive(Event, Clone, Debug)]
struct LobbyJoined(Lobby);

impl Plugin for MyPlugin {
    fn build(&self, app: &mut App) {
        app.add_crossbeam_event::<LobbyJoined>();
        app.add_startup_system(setup);
        app.add_observer(handle_lobby_joined);
    }
}

Fire events by using Res<CrossbeamEventSender<EventType>> (which can be cloned and sent into callbacks):

fn setup(service: Res<ThirdPartyCode>, sender: Res<CrossbeamEventSender<LobbyJoined>>) {
    let sender = sender.clone();
    service.join_lobby(id, move |lobby| {
        sender.send(LobbyJoined(lobby));
    });
}

Handle the events with observers:

fn handle_lobby_joined(lobby_joined: On<LobbyJoined>) {
    info!("lobby joined: {:?}", lobby_joined.0);
}

Bevy Version Support

The main branch targets the latest bevy release.

bevy bevy_crossbeam_event
0.18 0.10, main
0.17 0.9
0.16 0.8
0.15 0.7
0.14 0.6
0.13 0.5
0.12 0.3
0.11 0.2
0.10 0.1

In Bevy 0.17, events changed functionality and became what was previously known as "triggers", if you prefer the old behavior with asyncronous messages, check out bevy_channel_message.

License

bevy_crossbeam_event is dual-licensed under either

at your option.

Contributions

PRs welcome!

Dependencies

~21–34MB
~555K SLoC