# A2uiCoreSurfaceModel

Artifact: [androidx.a2ui:a2ui-engine](https://developer.android.com/jetpack/androidx/releases/a2ui) [View Source](https://cs.android.com/search?q=file:androidx/a2ui/engine/model/A2uiCoreSurfaceModel.kt+class:androidx.a2ui.engine.model.A2uiCoreSurfaceModel) Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

*** ** * ** ***


```
class A2uiCoreSurfaceModel : A2uiSurfaceModel
```

<br />

*** ** * ** ***

The root domain model for a single active surface.

It acts as the owner of that surface's `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreDataModel` and `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry`, managing updates to these registries and propagating user actions and validation/runtime errors.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#A2uiCoreSurfaceModel(kotlin.String,androidx.a2ui.engine.catalog.A2uiCoreCatalog,androidx.a2ui.engine.platform.A2uiCoreDataModel,androidx.a2ui.engine.platform.A2uiCoreComponentRegistry,kotlin.Function1,kotlin.Function1,kotlin.collections.Map,kotlin.Boolean,kotlin.Function0)( id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, catalog: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/catalog/A2uiCoreCatalog, dataModel: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreDataModel, componentRegistry: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry, onDispatchAction: (https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiUserAction) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, onDispatchError: (https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiClientErrorMessage) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, theme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>, shouldSendDataModel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, timeProvider: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchAction(kotlin.String,kotlin.collections.Map)(componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, actionDefinition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>)` Dispatches a user action from this surface to the registered action handler callback. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchError(androidx.a2ui.model.protocol.A2uiException,kotlin.String)(exception: https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiException, componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Reports a rendering or evaluation failure to the component registry and dispatches the error to the registered error handler callback. |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#evaluatePayload(kotlin.String,androidx.a2ui.engine.model.A2uiCoreValueResolver,androidx.a2ui.model.protocol.A2uiDataPath,kotlin.Any)( componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, valueResolver: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreValueResolver, dataPath: https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiDataPath, payload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html? )` Evaluates a dynamic payload for a specific component. |
| `open T` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)( componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, functionDefinition: https://developer.android.com/reference/kotlin/androidx/a2ui/model/catalog/A2uiFunctionDefinition, factory: () -> T )` Gets or creates a component-scoped cache for `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)`. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#toString()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/catalog/A2uiCoreCatalog` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#catalog()` The catalog used in this surface. |
| `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#componentRegistry()` The component registry backing this surface. |
| `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreDataModel` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dataModel()` The storage model for this surface's data tree. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#id()` The unique identifier of this surface. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#shouldSendDataModel()` If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#theme()` An optional map of theme-specific overrides for this surface. |

## Public constructors

### A2uiCoreSurfaceModel

```
A2uiCoreSurfaceModel(
    id: String,
    catalog: A2uiCoreCatalog,
    dataModel: A2uiCoreDataModel,
    componentRegistry: A2uiCoreComponentRegistry,
    onDispatchAction: (A2uiUserAction) -> Unit,
    onDispatchError: (A2uiClientErrorMessage) -> Unit,
    theme: Map<String, Any?> = emptyMap(),
    shouldSendDataModel: Boolean = false,
    timeProvider: () -> Long = { System.currentTimeMillis() }
)
```

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The unique identifier of this surface. |
| `catalog: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/catalog/A2uiCoreCatalog` | The catalog used in this surface. |
| `dataModel: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreDataModel` | The storage model for this surface's data tree. |
| `componentRegistry: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry` | The component registry backing this surface. |
| `onDispatchAction: (https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiUserAction) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Callback to handle user actions dispatched from this surface. |
| `onDispatchError: (https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiClientErrorMessage) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Callback to handle errors dispatched from this surface. |
| `theme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> = emptyMap()` | An optional map of theme-specific overrides for this surface. |
| `shouldSendDataModel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server. |
| `timeProvider: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = { System.currentTimeMillis() }` | Provider that returns the current epoch time in milliseconds. |

## Public functions

### dispatchAction

```
fun dispatchAction(componentId: String, actionDefinition: Map<String, Any?>): Unit
```

Dispatches a user action from this surface to the registered action handler callback.

| Parameters |
|---|---|
| `componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The unique identifier of the component that was interacted with. |
| `actionDefinition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | A map containing details about the action (e.g., name, context). |

### dispatchError

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
fun dispatchError(exception: A2uiException, componentId: String? = null): Unit
```

Reports a rendering or evaluation failure to the component registry and dispatches the error to the registered error handler callback.

**Note:** The `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchError(androidx.a2ui.model.protocol.A2uiException,kotlin.String)` is exclusively used to mark the error on the local component registry for local UI error boundary rendering. It is **not** appended or injected into the exception context or path sent to the server. Callers must ensure the `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchError(androidx.a2ui.model.protocol.A2uiException,kotlin.String)` itself is initialized with all the relevant information, including the component id if relevant.

| Parameters |
|---|---|
| `exception: https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiException` | The exception describing the failure. |
| `componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html? = null` | The unique identifier of the component that encountered the error. Null if the error is surface-level. |

### equals

```
open operator fun equals(other: Any?): Boolean
```

### evaluatePayload

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
fun evaluatePayload(
    componentId: String,
    valueResolver: A2uiCoreValueResolver,
    dataPath: A2uiDataPath,
    payload: Any?
): Any?
```

Evaluates a dynamic payload for a specific component.

| Parameters |
|---|---|
| `componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | unique identifier of the UI component |
| `valueResolver: https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreValueResolver` | resolver to retrieve values from the data model |
| `dataPath: https://developer.android.com/reference/kotlin/androidx/a2ui/model/protocol/A2uiDataPath` | base path used to resolve relative paths |
| `payload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | payload to evaluate |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | evaluated result, or null if evaluation fails |

### getOrCreateFunctionScopedCache

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
open fun <T : Any> getOrCreateFunctionScopedCache(
    componentId: String,
    functionDefinition: A2uiFunctionDefinition,
    factory: () -> T
): T
```

Gets or creates a component-scoped cache for `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)`.

Each component and `https://developer.android.com/reference/kotlin/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)` pair gets a separate cache that persists across function invocations and data model updates. Ideal for storing the results of heavy operations that do *not* rely on data model values (e.g., static metadata, parsed templates, compiled regexes, etc.).

Warning: The cache does not refresh upon data model changes. Caching values that are based on the data model will result in a stale cache.

| Parameters |
|---|---|
| `componentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | unique identifier of the component |
| `functionDefinition: https://developer.android.com/reference/kotlin/androidx/a2ui/model/catalog/A2uiFunctionDefinition` | definition identifying the cache |
| `factory: () -> T` | factory function to create the cache if missing |

| Returns |
|---|---|
| `T` | cache instance |

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### catalog

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
val catalog: A2uiCoreCatalog
```

The catalog used in this surface.

### componentRegistry

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
val componentRegistry: A2uiCoreComponentRegistry
```

The component registry backing this surface.

### dataModel

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
val dataModel: A2uiCoreDataModel
```

The storage model for this surface's data tree.

### id

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
open val id: String
```

The unique identifier of this surface.

### shouldSendDataModel

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
val shouldSendDataModel: Boolean
```

If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server.

### theme

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
val theme: Map<String, Any?>
```

An optional map of theme-specific overrides for this surface.