#NonSend plugins

4 messages · Page 1 of 1 (latest)

sage saffron
#

Is there a bevy way of writing non-send plugins? I'm currently resorting to extension methods but would prefer something more familiar. I've also tried messing around with Arc<Mutex<T>> but it seems that doesn't work for types like JsValue.

#[extend::ext]
pub impl App {
  fn add_transport<T: 'static + Transport>(
    &mut self,
    transport: T,
  ) -> &mut Self {
    self
      .insert_non_send_resource(transport)
      .add_systems(
        Update,
        (
          transport_incoming::<T>
          transport_outgoing::<T>
        ),
    );
    self
  }
}
subtle yacht
#

This is for... non-Rust interop?

#

Fundamentally no though: Plugin requires Send + Sync

#

(we could maybe relax that?)