Property Inheritance

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

  1. Properties can be marked as inheritable
  2. Child nodes automatically inherit parent values
  3. Children can override inherited values
  4. 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

  1. Automatic Propagation

    • Values flow down the tree
    • Updates trigger automatically
    • Efficient change notification
  2. Override Control

    • Override at any level
    • Restore inherited values
    • Clear local values
  3. Default Values

    • Fallback values
    • Reset to defaults
    • Clear inheritance chain