Class PropBindingControl<T>
Type Parameters
- T
Type accepted by the supplied predicate and returned by the controller.
Constructors
constructor
-
Creates a property binding controller.
The fallback must satisfy the supplied predicate because it is guaranteed to be returned whenever no higher-precedence value is valid.
Type Parameters
- T
Type accepted by the supplied predicate and returned by the controller.
Parameters
- predicate: TypePredicate<T>
Type predicate used to validate the bindable property, candidate values, and fallback.
- fallback: T
Component-owned fallback returned when no direct value or candidate satisfies
predicate.
Returns PropBindingControl<T>
- T
Methods
resolve
-
Resolves the effective value and records it as the value published back through the bindable component property.
A
boundValuediffering from the value returned by the previous invocation is treated as an external assignment. When valid, it becomes the direct value and takes precedence over all candidates. When invalid, any previous direct value is cleared.When
boundValuematches the previously published value, it is recognized as the component's own assignment and does not alter direct-value provenance.Candidates are evaluated from left to right. The first candidate accepted by the configured predicate is returned. If neither a direct value nor a candidate is valid, the constructor fallback is returned.
The returned value should normally be assigned directly back to the bindable property:
$: store = storeControl.resolve(store, inputOptions.store);Parameters
- boundValue: unknown
Current value of the exported bindable property.
- ...candidates: readonly unknown[]
Additional candidate values evaluated in descending precedence order.
Returns T
The valid direct value, first valid candidate, or fallback.
- boundValue: unknown
Resolves a bindable component property while preserving the provenance of values published by the component.
PropBindingControlsupports component properties that serve as both:This distinction is important when a component resolves a property from multiple sources. Once the component publishes a resolved value back through the bound property, that value must not subsequently be interpreted as a new direct value supplied by the parent.
The controller records the last value it published. When resolve is called, a bound value that differs from the last published value is treated as an external assignment and becomes the highest-precedence direct value. Otherwise, the controller resolves the first valid candidate or returns its component-owned fallback.
Resolution precedence is:
An invalid external assignment clears any previously established direct value, allowing candidate values or the fallback to become effective again.
The controller does not subscribe to, observe, or dispose of resolved values. It only retains references required to track resolution provenance. Consequently, a component-local instance does not require explicit cleanup.
Example: Svelte component store resolution