mirror of
https://github.com/bevyengine/bevy
synced 2025-01-03 08:48:57 +00:00
d90cb57c2e
Hi, this is a minimal implementation of #12159. I wasn't sure if the `EventLoopProxy` should be wrapped somewhat to make it more explicit. # Objective Minimal implementation of #12159 When using `UpdateMode::Reactive` it is currently not possible to request a redraw when a long running task is finished or an external source has new data. This makes the following possible which will then run an app update once ``` rust // EventLoopProxy is Send on most architectures // The EventLoopProxy can also be saved in a thread local for WASM or a static in other architecturecs pub fn example(proxy: NonSend<EventLoopProxy<()>>) { let clone: EventLoopProxy<()> = proxy.clone(); thread::spawn(move || { // do long work clone.send_event(()); }); } ``` ## Solution By using the EventLoopProxy one can manually send events from external threads to the event loop as `UserEvent`s. This simply sets redraw_requested when a `UserEvent` is received. ## Changelog - Added the ability to request a redraw from an external source --------- Co-authored-by: Kellner, Robin <Robin.Kellner@vector.com> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |