Constructor
new AvenxComponent(initialStateopt, computedopt, bridgesopt, templateopt, methodsopt, propsopt, stylesopt, resourcesopt, optionsopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
initialState |
object |
<optional> |
The initial state of the component. |
computed |
object |
<optional> |
Computed properties definitions. |
bridges |
object |
<optional> |
External bridges accessible to the component. |
template |
string |
<optional> |
The HTML template string. |
methods |
object |
<optional> |
Component methods. |
props |
object |
<optional> |
Component properties. |
styles |
object |
<optional> |
Component CSS variables. |
resources |
object |
<optional> |
Reactive resources. |
options |
object |
<optional> |
Component options and compiler contracts. |
Classes
Members
$app
Resolves the app instance associated with this component.
$app
Sets the app instance associated with this component.
$compiled
Whether this component renders through a compiled program.
Exposed for tests and diagnostics: "did this component take the fast path" is otherwise unanswerable from outside, and a performance property nobody can observe is a performance property nobody can defend.
$element
Getter for the component's root element.
$isMounted
Whether the component is currently mounted in the DOM.
$isUnmounted
Whether the component has been unmounted.
$keepAlive
KeepAlive invalidation API for clearing cached components.
$logContext
Returns component context metadata for diagnostic logging.
$parent :AvenxComponent|null
Type:
- AvenxComponent | null
$refs
Getter for component reference elements marked with data-ax-ref. Lazily resolves references if marked dirty.
$route
The current active route metadata.
$slots
Slot helpers for checking whether the parent provided content for a slot.
Available after mount target setup populates #transcludedGroups.
_scope :DisposalScope
Owns teardown callbacks created while this component runs its own code (lifecycle hooks, actions, event handlers). Bridge subscriptions register here and are released in __performTeardown().
Type:
_watchers :Array:.<AvenxWatcher:>
Type:
- Array:.<AvenxWatcher:>
contracts
Returns the set of active compiler contracts for this component.
Methods
$destroy() → {Promise:.<void:>|void}
Destroys/unmounts the component and performs teardown of watchers and resources. Alias for unmount().
Returns:
$emit(eventName, detailopt)
Emits a custom event to the parent component.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventName |
string | Name of the event to emit. |
|
detail |
object |
<optional> |
Event details. |
$inspect() → {Object}
Returns a diagnostic snapshot of the component for runtime debugging.
Props and state are sanitized clones (safe to log, serialize, or diff);
element is intentionally the live root element so it stays inspectable
in browser devtools. Computed properties are listed by key only, so
inspecting never evaluates them.
Returns:
- Type
- Object
$nextTick(callbackopt) → {Promise:.<void:>|void}
Executes a callback (or resolves a Promise) after the current reactive update cycle has finished flushing pending DOM updates.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
function |
<optional> |
Optional callback to run after the flush. |
Returns:
A promise resolving after the flush, if no callback was given.
$resetDeadlockBoundary(boundaryNameopt)
Resets a named deadlock boundary inside this component's DOM tree.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
boundaryName |
string | null |
<optional> |
null |
$tripDeadlockBoundary(boundaryNameopt, erroropt)
Trips a named deadlock boundary inside this component's DOM tree, rendering its fallback template.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
boundaryName |
string | null |
<optional> |
null | Name of the deadlock boundary (or null for first boundary). |
error |
Error | object |
<optional> |
Error context to pass to fallback template. |
$validateElement(el) → {Array:.<string:>}
Evaluates validation rules for an element and updates this.state.$validation.
Parameters:
| Name | Type | Description |
|---|---|---|
el |
Element | The element to validate. |
Returns:
Validation errors for the field.
$watch(source, callback, optionsopt) → {AvenxWatcher}
Reactively listens to changes in specific state values or getters.
Parameters:
Returns:
- Type
- AvenxWatcher
$watchEffect(effect, optionsopt) → {function}
Reactively runs an immediate effect hook that automatically tracks dependencies and re-runs on state mutation. Automatically registers the watcher in this._watchers and tears it down when the component unmounts.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
effect |
function | Effect function to run immediately and track. |
|
options |
object |
<optional> |
Config options. |
Returns:
Stop handle function () => watcher.teardown().
- Type
- function
__bridgeValues() → {object}
The bridges this component can see.
Returns:
Bridges by name.
- Type
- object
__buildScope() → {object}
Builds one evaluation scope, without evaluating anything in it.
Scope construction used to happen once per interpolation per render, which made it a hot path nobody could see. It is measurable from here.
Returns:
A fresh scope.
- Type
- object
__computedKeys() → {Array:.<string:>}
The names the component's computed values bind.
Read by ComponentScope; a component's computed registry is private and the scope has no business reaching into it.
Returns:
Computed names.
__evaluate(expression, extraScopeopt) → {any}
Evaluates one template expression against this component's scope.
Exposed for renderer benchmarks and tests, which need to price expression evaluation on its own rather than inferring it from a whole update.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
expression |
string | The expression source. |
|
extraScope |
object |
<optional> |
Additional scope bindings. |
Returns:
The value.
- Type
- any
__getTemplate() → {string}
The compiled template this component renders.
An internal seam, in the same family as __setMountTarget. Benchmarks and
renderer tests need the exact string the compiler produced, and reaching it
by recompiling the source would measure a reconstruction rather than what
the component actually holds.
Returns:
The template source.
- Type
- string
__hasImports() → {boolean}
Whether the component's module bound any imports.
Returns:
True when there are imports in scope.
- Type
- boolean
__importValues() → {object}
The values the component's module imported.
Returns:
Imported values by local name.
- Type
- object
__isIsolated() → {boolean}
Whether the component declared the isolated contract.
Returns:
True when bridges are kept out of scope.
- Type
- boolean
__methods() → {object}
The component's executable actions.
Returns:
The action map.
- Type
- object
__notifyInjectingChildren()
Notifies all registered injecting child components that a provided value has shifted.
__onChildPropsChanged()
Called when a compiled prop for a child component changed value.
A plain component does not mount children, so this is a no-op here. AvenxPage overrides it: pages own the child mount points, and a changed prop is the one thing that has to reach an already-mounted child.
__readResource(name) → {any}
Reads a resource, suspending if it is still in flight.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The resource name. |
Returns:
The resource's value.
- Type
- any
__registerInjectingChild(key, child)
Registers a child component that is injecting a provided key.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | The provided key. |
child |
AvenxComponent | The child component. |
__resourceNames() → {Array:.<string:>}
The names of the component's declared resources.
Returns:
Resource names.
__unregisterInjectingChild(key, child)
Unregisters an injecting child component.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | The provided key. |
child |
AvenxComponent | The child component. |
__updateProvidedState()
Dynamically re-evaluates the provide option and updates providedState.
(protected) _evaluate(expression, extraScopeopt) → {any}
Evaluates an expression in the component's scope.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
expression |
string | The expression to evaluate. |
|
extraScope |
object |
<optional> |
Additional scope variables. |
Returns:
The result of the evaluation.
- Type
- any
(protected) _getBridges() → {object}
Returns:
The bridges accessible to the component.
- Type
- object
(protected) _getElement() → {Element|null}
Returns:
The component's root element.
- Type
- Element | null
(protected) _getScopeValue(key) → {any}
Retrieves a property or method from the component's scope. Used for array-based provide to resolve keys dynamically.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | The key to retrieve. |
Returns:
The value.
- Type
- any
(protected) _getTranscludedGroups() → {object}
Retrieves the transcluded groups for this component.
Returns:
The transcluded groups.
- Type
- object
clearKeepAliveCache(pageNameopt) → {boolean}
Helper method to clear cached KeepAlive component instances.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
pageName |
string |
<optional> |
Optional component or page name to clear from cache. |
Returns:
True if cache entries were evicted, false otherwise.
- Type
- boolean
destroy() → {Promise:.<void:>|void}
Destroys/unmounts the component and performs teardown of watchers and resources. Alias for unmount().
Returns:
emit(eventName, detailopt, optionsopt)
Emits a custom event up to parent components with unified bubble options.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventName |
string | Name of the event to emit. |
|
detail |
object |
<optional> |
Event details payload. |
options |
object |
<optional> |
Optional custom event options. |
mount(target)
Mounts the component to a target element.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
Element | string | The target element or selector. |
nextTick(callbackopt) → {Promise:.<void:>|void}
Alias for AvenxComponent#$nextTick.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
function |
<optional> |
Optional callback to run after the flush. |
Returns:
onBeforeLeave() → {Promise:.<void:>|void}
Called before the component leaves the DOM. Can return a Promise to postpone DOM removal.
Returns:
onEnter()
Called when the component is mounted to the DOM and enters.
onLeave()
Called when the component is unmounted and leaves the DOM.
render() → {string}
Renders the component template with current state.
Returns:
The rendered HTML string.
- Type
- string
runUpdate()
Performs the actual update/render of the component.
scheduleUpdate()
Schedules an update to run asynchronously in a microtask.
setProps(newProps)
Updates the component's props and triggers an update if they changed.
Parameters:
| Name | Type | Description |
|---|---|---|
newProps |
object | The new props to apply. |
unmount() → {Promise:.<void:>|void}
Unmounts the component and triggers cleanup.
Returns:
update()
Renders the component.
On the compiled path this builds the DOM once and hands ownership to the per-binding effects; afterwards it is only reached when something outside the reactive graph asks for a re-read. On the string path it evaluates the render watcher, which re-renders and re-patches the whole template.
watch(getter, callback, optionsopt) → {AvenxWatcher}
Programmatically registers a watcher on a reactive expression/function.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
getter |
function | Evaluation function returning the value to watch. |
|
callback |
function | Triggered when the value changes. |
|
options |
object |
<optional> |
Config options. |
Returns:
- Type
- AvenxWatcher
(static) clearMixins()
Resets/clears the global mixins list. Useful for testing environments.
(static) extend(optionsopt) → {function}
Helper method to programmatically create component subclasses without ES class boilerplate.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
object |
<optional> |
Component definition options. |
Returns:
The generated component subclass.
- Type
- function
(static) mixin(mixin)
Registers a global mixin.
Parameters:
| Name | Type | Description |
|---|---|---|
mixin |
object | The mixin definition. |