applyDerivations
Applies all pending derivations from a collection.
This function processes derivations in order, evaluating conditions and computing values. It handles loop prevention through:
- Chain tracking (prevents same derivation from running twice in one cycle)
- Value equality checks (skips if target already has computed value)
- Max iteration limit (safety fallback)
Presentation
function applyDerivations (
collection: DerivationCollection ,
context: DerivationApplicatorContext ,
changedFields?: Set<string> | undefined,
): DerivationProcessingResult ;Returns
Parameters
| Name | Type | Description |
|---|---|---|
| collection | | The collected derivation entries |
| context | | Context for applying derivations |
| changedFields | Set<string> | undefined | Set of field keys that changed (for filtering) |
Example usage
const result = applyDerivations (collection, {
formValue: formValueSignal,
rootForm: form(),
derivationFunctions: customFnConfig?.derivations,
logger: inject(DynamicFormLogger ),
});
if (result.maxIterationsReached) {
console.warn('Possible derivation loop detected');
}