EvaluationScope

sealed interface EvaluationScope

Where a relative data binding resolves from, and what @index returns.

A component renders in the root scope by default. A container whose children are a dev.ynagai.a2ui.core.protocol.ChildList.Template instantiates its template once per item of the bound array, and each instance renders in a collection scope whose base is that item.

The chain is kept rather than flattened to a single base pointer because @index reads the innermost iteration index, which a flattened base cannot recover: /rows/2/cells/0 does not say whether the enclosing loop is over cells or rows.

Inheritors

Types

Link copied to clipboard
data class Collection(val parent: EvaluationScope, val path: JsonPointer, val index: Int) : EvaluationScope

One item of a list template, nested inside parent.

Link copied to clipboard
data object Root : EvaluationScope

The scope every surface starts in, where relative and absolute pointers coincide.

Properties

Link copied to clipboard
abstract val base: JsonPointer

The pointer that a relative binding in this scope is measured from.

Link copied to clipboard
open val index: Int?

The 0-based index of the item being iterated, or null outside a list template.

Functions

Link copied to clipboard

The index @index reads here, or null when this scope is not inside a list template.

Link copied to clipboard

The scope for item index of a template bound to path, nested inside this scope.

Link copied to clipboard

pointer rebased on this scope: absolute pointers unchanged, relative ones measured from EvaluationScope.base.

Link copied to clipboard
fun EvaluationScope.resolve(dataModel: JsonElement, pointer: JsonPointer): JsonElement?

The value pointer addresses in dataModel once rebased on this scope, or null when absent.