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§

source

fn spawn_task<T, F>(&mut self, task: T)
where T: FnOnce(TaskContext) -> F + Send + 'static, F: Future<Output = ()> + Send + Sync + 'static,

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.

Implementations on Foreign Types§

source§

impl SpawnCommandExt for Commands<'_, '_>

source§

fn spawn_task<T, F>(&mut self, task: T)
where T: FnOnce(TaskContext) -> F + Send + 'static, F: Future<Output = ()> + Send + Sync + 'static,

Implementors§