Core Elements

Core Elements are the building blocks of the Matrix Framework, representing individual nodes in the middleware tree.

Overview

Each Core Element is a node in the tree that can:

  • Hold properties and state
  • Handle events
  • Maintain parent-child relationships
  • Process messages

Key Features

  • Property Management: Each element has a properties map
  • Event Handling: Elements can process and route events
  • Tree Navigation: Elements know their position in the tree
  • Message Processing: Elements can transform and handle messages

Example

const element = new CoreElement();
element.properties.set("name", "MyElement");
element.on("message", async (ctx, next) => {
    // Handle message
    await next();
});