Skip to content

Function: composeViews()

API / @xmachines/play-view / index / composeViews

function composeViews(tree): ComposedView;

Defined in: packages/play-view/src/compose-views.ts:173

Grafts the views of a ViewTree into one flat spec.

Each child view goes into the outlet of its key, or into the "*" outlet. A child with neither outlet stays off the screen. The child root lands at the END of the children or of the named slot of the outlet element, after the elements that the parent put there itself, and the children of a parallel state land in the order of the machine.

The function makes a NEW object on each call. A caller that emits the composed view on each snapshot keeps one result for each tree, so that elements and viewParts keep their identity: play-xstate keeps one for each tree of each machine.

Parameters

ParameterTypeDescription
treeViewTreeThe resolved views, from the outermost view that declares outlets.

Returns

ComposedView

The static half of the composed view.

Throws

When an outlet names an element that its view does not hold.

Throws

When two views of the composition hold an element with the same key.