Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AGenUI AGenUI Component Model And Data Binding

From Leeroopedia
Knowledge Sources
Domains UI_Framework, Data_Binding
Last Updated 2026-10-24 17:21 GMT

Overview

A component model with reactive data binding where each component holds typed attribute values that subscribe to data-model paths, automatically re-rendering when bound data changes and supporting bidirectional synchronization.

Description

Data binding connects a UI component's attributes to an underlying data model so that changes in the data automatically propagate to the view, and user interactions propagate back to the data. This eliminates manual synchronization code and enables declarative UI definitions.

The `ComponentModel` represents a single component in the virtual DOM. Each attribute is stored as a `DataValue` — a typed value object that may be a static literal, a data binding (`{"path": "user.name"}`), a function call (`{"call": "formatCurrency", ...}`), or an action (`event` or `functionCall`). When an attribute is a data binding, the `AttributeDataBinder` subscribes to the data model path; when the data at that path changes, the binder notifies the component via `onComponentAttributeDataChanged`, triggering a re-evaluation and diff emission.

Bidirectional synchronization is handled by `syncValue()`: when a user interacts with an input component (e.g., typing in a text field), the platform calls `submitUIDataModel()`, which flows to `ComponentModel::syncValue()`, updating the bound `DataBindingDataValue` with the new value. This propagates back to the data model.

Action execution is handled by `executeAction()`: user interactions trigger actions that may be event-based (dispatched via `EventDispatcher::dispatchActionEventRouted`) or function-call-based (executed via `FunctionCallActionDataValue::execute()`). Caller-supplied context actions can override the component's own action attribute.

Usage

Use this principle when:

  • UI components need reactive binding to a data model
  • Component attributes may be static, data-bound, or function-call expressions
  • User interactions must propagate back to the data model (bidirectional)
  • Actions (events, function calls) must be triggered by user interaction

Theoretical Basis

The data binding subscription model:

ComponentModel
├── _attributes["text"] = DataBindingDataValue(path="user.name")
│     └── AttributeDataBinder subscribes to DataModel["user.name"]
│           onDataChanged → onComponentAttributeDataChanged("text")
│             → re-evaluate → emit diff to native renderer
└── _attributes["action"] = EventActionDataValue(...)
      └── executeAction(surfaceId, dispatcher)
            → EventActionDataValue.execute() → dispatchActionEventRouted

The bidirectional sync flow:

User types in TextField
  → submitUIDataModel(SyncUIToDataMessage)
    → SurfaceCoordinator.handleSyncUIToData()
      → Surface.syncUIToData(componentId, change)
        → ComponentModel.syncValue("value", newText)
          → DataBindingDataValue.syncBindingValue(newText)
            → DataModel updated at bound path

Practical Guide

  • Components are created by `ComponentManager::parseComponent()` from A2UI protocol JSON.
  • Data bindings use `{"path": "dataModel.path"}` syntax in attribute values.
  • Actions use `{"event": {...}}` or `{"functionCall": {...}}` in the `action` attribute.
  • Use `syncValue()` to push user input back to the data model for controlled components.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment