Skip to main content

Module fragments

Module fragments 

Source
Expand description

Fragments at run time: the app’s declared fragment set, the marker a fragment instance carries, and the argument binding an instantiation resolves its placeholders against.

A fragment is compiled once and instantiated many times. The compiler puts every declaration in the artifact’s FragmentTable; FragmentLibrary is that table as a world resource, so anything holding the world can instantiate by key. The instantiation itself lives with the rest of the DOM command applier, which is the only caller.

Arguments are static: they substitute once, when the instance is built. A value that changes while the app runs is a bind-* attribute inside the fragment body, which the spawn path seeds and the per-tick binding systems drive. FragmentInstance records what an instance was built with, which is what a build reads back to write a component’s body into the document it emits.

Structs§

FragmentInstance
Marks the root of an instantiated fragment with the key it came from and the arguments it was built with.
FragmentLibrary
The app’s declared fragments, keyed by fragment key.
SlotPlaceholder
Marks a spawned <slot>: the element a use site’s child replaces.

Enums§

FragmentFault
Why a fragment could not be instantiated.

Functions§

bind_args
Bind the fragment’s parameters: every declared parameter takes its default, then the use site’s arguments override. An argument naming something the fragment does not declare is kept, so a body written against a wider parameter list than its declaration still resolves.
install
Put the app’s declared fragments in world, replacing whatever set was there.
instance_body
The element an instance spawns from, or why it cannot.
report_once
Report a fragment fault once per (key, fault) pair. A command issued every tick reports the first time and stays quiet after, so a broken key is visible without flooding the log.
slot_name_of
The slot name an element occupies, or None when it is not a slot.