DerivationLookup
| Decorators: | @Injectable |
Provides lazy-computed lookup maps for derivation entries.
Instead of pre-computing all lookup maps at collection time (which caused hidden mutation and bloated the DerivationCollection god object), this class computes maps lazily on first access and caches them.
Accessors
get byArrayPath |
|---|
Map of array path to entries that derive array item values. Used for O(1) lookup when an array field changes. |
Presentation |
Type
|
get byDependency |
|---|
Map of dependency field key to entries that depend on it. Used for efficient O(1) lookup when filtering by changed fields. |
Presentation |
Type
|
get byField |
|---|
Map of field key to entries that target it. Since derivations are self-targeting, this maps field keys to their derivations. Used for quick lookup when processing derivations. |
Presentation |
Type
|
get entries |
|---|
Current derivation entries (from signal). Auto-invalidates cache if entries reference changed. |
Presentation |
Type |
get wildcardEntries |
|---|
Entries that have wildcard (*) dependency. These entries depend on all form values and must always be considered. |
Presentation |
Type |
Methods
getDebouncedEntries() | ||||||
|---|---|---|---|---|---|---|
Gets entries with trigger 'debounced' for a specific debounce period. | ||||||
Presentation | ||||||
Parameters
Returns |
getDebouncePeriods() |
|---|
Gets all unique debounce periods that have entries. |
Presentation |
Returnsnumber[] |
getEntriesForChangedFields() | ||||||
|---|---|---|---|---|---|---|
Gets entries that should be processed based on changed fields. Handles nested path matching: if 'address' changed, entries depending on 'address.city' will also be included (parent change implies child changed). Uses O(k) lookup via indexed maps for exact matches, plus O(d) scan for nested dependencies, where k = changed fields, d = unique dependencies. | ||||||
Presentation | ||||||
Parameters
Returns |
getOnChangeEntries() |
|---|
Gets entries with trigger 'onChange' (or no trigger, which defaults to onChange). |
Presentation |
Returns |
invalidateCache() |
|---|
Invalidates cached maps. Call this when entries change. |
Presentation |
Returnsvoid |
Example usage
const lookup = inject(DerivationLookup );
// Lazy-computed on first access
const entriesForQuantity = lookup.byDependency.get('quantity');
const onChangeEntries = lookup.getOnChangeEntries();