Skip to main content

reconcile_for_blocks

Function reconcile_for_blocks 

Source
pub fn reconcile_for_blocks(
    array_signals: Res<'_, ArraySignals>,
    store: Res<'_, PropertyStore>,
    markers: Query<'_, '_, (Entity, &mut ForMarker, Option<&Children>)>,
    commands: Commands<'_, '_>,
    lookup: RowLookup<'_, '_>,
    parents: Query<'_, '_, &ChildOf>,
    scroll_state: Query<'_, '_, (&ScrollOffset, &Transform), With<Scroll>>,
    styles: Query<'_, '_, &Style>,
    stylesheet: Option<Res<'_, LumenStylesheet>>,
    policy: Option<Res<'_, ScenePolicy>>,
)
Expand description

Reconcile every <for> block against the current ArraySignals state.

Reconciliation policy (alpha7):

  • Equal key sequence -> nothing mounts or unmounts.
  • In every case that keeps rows, a kept row whose record changed has its placeholders resolved again and written onto its existing entities, so it keeps focus / scroll / animation state and shows the new record. A row the template no longer lines up with (a script reshaped it, or the change reaches a nested <for> / <if> body or a component use site) cannot follow in place and the block rebuilds.
  • New keys are an extension of cached (cached is a prefix of new) -> spawn only the appended items. Common case: signal_array.push(...) adds one item, only the new row spawns; existing rows keep their focus / scroll / Signals state.
  • Cached keys are an extension of new (new is a prefix of cached) -> despawn only the trailing entities. Common case: pop / clear-tail.
  • Anything else (reorder, mid-insert, mid-remove) -> full rebuild. Real keyed reconciliation across arbitrary reorders requires re-anchoring ChildOf in bevy_ecs and lands as a follow-up.