spawn

Function spawn 

Source
pub fn spawn<'a, B>(bundle: B) -> Spawn<'a>
where B: Bundle + Clone,
Available on crate feature ecs only.
Expand description

Create a Spawn composable that spawns the provided bundle when composed.

On re-composition, the spawned entity is updated to the latest provided value.

ยงExamples

use actuate::prelude::*;
use bevy::prelude::*;

#[derive(Data)]
struct Button {
    label: String,
    color: Color
}

impl Compose for Button {
    fn compose(cx: Scope<Self>) -> impl Compose {
        // Spawn an entity with a `Text` and `BackgroundColor` component.
        spawn((Text::new(cx.me().label.clone()), BackgroundColor(cx.me().color)))
    }
}