Constructor
new ComponentScope(owner)
Parameters:
| Name | Type | Description |
|---|---|---|
owner |
object | The component this scope belongs to. |
Members
base :object|null
The base scope, built on first use and reused until invalidated.
Type:
- object | null
methods :object|null
The method map the cached base scope was built against.
A component's actions are established once, but createMethodMap hands
the scope builder the map it is still filling, so the first scopes are
built against an object that is not yet complete. Recording which map the
cache belongs to is what stops a stale one being reused.
Type:
- object | null
owner :object
Type:
- object
stateKeys :Array:.<string:>|null
The names the state layer binds, cached because computing them is
Object.keys() over the whole state object and a scope used to be built
per expression evaluated.
Type:
Methods
() → {Array:.<string:>}
The names provide/inject makes visible.
The names are a property of the component's inject declaration and do not
change; the values behind them do, because a provider higher up the tree
can update one at any time. So the names are resolved once and the values
are read live -- caching the values is what made a child keep rendering the
theme its ancestor no longer provides.
Returns:
The injected names.
(methods) → {object}
Builds the layered scope.
Parameters:
| Name | Type | Description |
|---|---|---|
methods |
object | The component's executable actions. |
Returns:
The scope proxy.
- Type
- object
invalidate()
Discards the cached scope.
Called when something changes what a name would resolve to. Cheap enough to call speculatively: the cost is one scope rebuild on the next evaluation.
invalidateKeys()
Discards only the cached state-key list.
A key being added to or removed from state changes what the state layer binds but not the shape of the scope, so the layers themselves survive.
keys() → {Array:.<string:>}
The names state and computed values bind.
Read from the raw target and the compiler's computed list rather than by enumerating the proxy, so building a scope registers no dependency and evaluates no computed value.
Returns:
The bound names.
resolve(methodsopt, extrasopt) → {object}
The scope an expression should be evaluated against.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
methods |
object |
<optional> |
The action map to expose. Defaults to the owner's. |
|
extras |
object |
<optional> |
null | Per-call bindings layered on top. |
Returns:
The scope.
- Type
- object