Skip to content

ComponentEx.addChild method

ComponentEx › addChild

Adds a child component.

Mirrors the native Component.addChild contract: if this component is already loaded, the child is loaded immediately, so child._loaded is set before this method returns even when this component has async load logic. The child's async tail (if any) is sequenced into the load promise so a later loadWithPromises call awaits it.

Adding a child BEFORE the first load is legitimate: the child is queued and loaded when this component loads. Adding one AFTER this component has been unloaded is not — the child would never be loaded and never unloaded (a leak), so it is refused with a SilentError. The typical source of such a call is an async method that was suspended on an await when the component got unloaded and then resumed on the dead component; the SilentError unwinds it quietly (see isUnloaded).

Signature:

addChild(component: TComponent): TComponent

Parameters:

ParameterTypeDescription
componentTComponentThe component instance to add.

Returns: TComponentThe added component.