RunDeferredSystem

Trait RunDeferredSystem 

Source
pub trait RunDeferredSystem {
    // Required methods
    fn run_deferred_system<S, M>(
        &mut self,
        schedule: S,
        system: impl Static + IntoSystem<(), (), M>,
    )
       where S: ScheduleLabel;
    fn run_deferred_system_with<S, I, M>(
        &mut self,
        schedule: S,
        system: impl Static + IntoSystem<In<I>, (), M>,
        input: I,
    )
       where S: ScheduleLabel,
             I: Static;
}
Expand description

Trait used to run deferred systems via World.

Required Methods§

Source

fn run_deferred_system<S, M>( &mut self, schedule: S, system: impl Static + IntoSystem<(), (), M>, )
where S: ScheduleLabel,

Queues the given System for a single execution in the given Schedule.

§Usage

You must add DefaultDeferredSystemsPlugin for deferred system execution to work in standard Bevy schedules. You may also add run_deferred_systems manually to any Schedule to provide deferred system execution support for it.

§Example
use bevy::prelude::*;
use bevy::ecs::world::DeferredWorld;
use bevy::ecs::lifecycle::HookContext;
use moonshine_util::prelude::*;

#[derive(Component)]
#[component(on_insert = on_insert_foo)]
struct Foo;

fn on_insert_foo(mut world: DeferredWorld, ctx: HookContext) {
    world.run_deferred_system(PostUpdate, |query: Query<&Foo>| {
        // ...
    });
}
Source

fn run_deferred_system_with<S, I, M>( &mut self, schedule: S, system: impl Static + IntoSystem<In<I>, (), M>, input: I, )
where S: ScheduleLabel, I: Static,

Same as run_deferred_system, but for systems with input parameters.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RunDeferredSystem for DeferredWorld<'_>

Source§

fn run_deferred_system<S, M>( &mut self, schedule: S, system: impl Static + IntoSystem<(), (), M>, )
where S: ScheduleLabel,

Source§

fn run_deferred_system_with<S, I, M>( &mut self, schedule: S, system: impl Static + IntoSystem<In<I>, (), M>, input: I, )
where S: ScheduleLabel, I: Static,

Source§

impl RunDeferredSystem for World

Source§

fn run_deferred_system<S, M>( &mut self, _schedule: S, system: impl Static + IntoSystem<(), (), M>, )
where S: ScheduleLabel,

Source§

fn run_deferred_system_with<S, I, M>( &mut self, _schedule: S, system: impl IntoSystem<In<I>, (), M> + 'static, input: I, )
where S: ScheduleLabel, I: Static,

Implementors§