Skip to main content

fill_components

Function fill_components 

Source
pub fn fill_components<H: ScriptHost + Resource<Mutability = Mutable>>(
    host: ResMut<'_, H>,
    pending: Query<'_, '_, (Entity, &PendingFill)>,
    reported: Local<'_, HashSet<String>>,
    commands: Commands<'_, '_>,
    events: MessageWriter<'_, ScriptCommandEvent>,
)
Expand description

Fill every use site the build could not finish by calling the function it names and putting the node that call returns in the marker’s place.

A component element names a script function. Where instantiating the block that function returns is the same as calling it, the build already put the block in the tree and no marker was left. Where the function has to run, because it works a value out or picks between blocks, the build left one element carrying [PendingFill] and this is what runs it.

The call’s own commands go out first, so the subtree it built exists by the time the replacement names it; the reserved token the host minted resolves inside the same batch. The marker is dropped on the way, so a filled site fills once.

Every tick rather than once: a subtree spawned while the app runs can carry a marker of its own.

Only the host that compiles markup blocks runs this, because that is the only host a marker can name a function in. A function it does not declare is a program that failed to load or an artifact that lost it: reported once and the marker dropped, rather than retried against a program that will never have it. Loud, because what it leaves behind is an empty element, which is exactly what a reader would not notice.