Overview
x(Component, props) is the primary composition primitive. Call it inside any html template to embed a child component. Mates registers the child with its scheduler — only the components whose reactive dependencies changed re-render, not the entire tree.
view() and template() are exact aliases of x() — same implementation, same runtime behaviour. Pick the name that reads most clearly in your codebase.
renderApp(Component, element) is the entry point. Call it once at application startup to mount the root component into a real DOM element. Optionally pass a third argument with initial props that will be forwarded to the root component's propsFn.
x() · view() · template() — identical aliases
|
Name
|
Identical to
|
Notes
|
|---|---|---|
x(C, props)
| primary | Short, idiomatic. Preferred for templates with many embeddings. |
view(C, props)
| alias of x() | More readable in prose-heavy code; same runtime path. |
template(C, props)
| alias of x() | Useful when naming the abstraction 'template' is clearer. |
Composing components
PostCard embeds Avatar using
x(). Each x() call is handled by the
scheduler — Mates re-renders only the parts of the tree whose reactive
dependencies changed.
x · view · template — identical
view() and template() are aliases of x(). Pick the name that reads clearest; runtime behaviour is identical.
Lazy load via async x()
Pass an async loader to x() — Mates resolves
it and mounts the component. See
Lazy Components for
resolveAsyncValue, isXViewTemplate, and
Router usage.