Trait bevy_mod_async::SpawnCommandExt
source · pub trait SpawnCommandExt {
// Required method
fn spawn_task<T, F>(&mut self, task: T)
where T: FnOnce(TaskContext) -> F + Send + 'static,
F: Future<Output = ()> + Send + Sync + 'static;
}
Required Methods§
sourcefn spawn_task<T, F>(&mut self, task: T)
fn spawn_task<T, F>(&mut self, task: T)
Spawn a task onto Bevy’s async executor. The AsyncComputeTaskPool
must be initialized before this command is applied (this typically
happens automatically with
DefaultPlugins
registered).
commands.spawn_task(|cx| {
// Will spawn an entity once we have exclusive world access and
// return the id
let _spawned = cx.with_world(|world| world.spawn(()).id()).await;
});
Object Safety§
This trait is not object safe.