Property Inheritance
Property Inheritance in Matrix Framework allows properties to be inherited through the middleware tree hierarchy.
Overview
The feature enables:
- Value propagation through the tree
- Override at any level
- Default value fallback
How It Works
- Properties can be marked as inheritable
- Child nodes automatically inherit parent values
- Children can override inherited values
- Changes propagate to descendants
Example
class ThemeComponent extends CoreElement {
public readonly themeProperty = new InheritableProperty<string>("light");
}
class ChildComponent extends CoreElement {
constructor() {
super();
// Will inherit theme from parent
this.inheritProperty("theme");
}
}
const parent = new ThemeComponent();
const child = new ChildComponent();
parent.addChild(child);
// Child inherits "light" theme
console.log(child.getProperty("theme")); // "light"
// Change parent theme
parent.themeProperty.value = "dark";
// Child automatically updates
console.log(child.getProperty("theme")); // "dark"
Key Features
-
Automatic Propagation
- Values flow down the tree
- Updates trigger automatically
- Efficient change notification
-
Override Control
- Override at any level
- Restore inherited values
- Clear local values
-
Default Values
- Fallback values
- Reset to defaults
- Clear inheritance chain