A2UICore.Resolution.Binder (A2UICore v0.1.1)

Copy Markdown View Source

Resolves a component's properties to the values a renderer displays.

The component's catalog schema says how each property behaves:

  • dynamic (DynamicString, DataBinding, … — anything that may be a binding or a function call) — evaluated against the data model;
  • action — kept as the raw action object, to be resolved with A2UICore.Resolution.DataContext.resolve_action/2 when triggered;
  • structural (ChildList, ComponentId, templates) — kept as is, for the node resolver to expand;
  • checkable — the rule list is kept and the owning object gains "isValid", "validationErrors" and "validationResult";
  • objects and arrays are resolved member by member.

Where the schema says nothing (a component whose schema is an allOf envelope, an unknown component, a property the schema does not declare) the behavior is inferred from the value's shape, as the reference binder does.

The result is a snapshot: bind/4 is pure and returns the resolved properties together with the warnings and errors raised while evaluating them (A2UICore.Resolution.DataContext.effect/0). Reactive updates are the host's job — it rebinds when the data model or the component changes.

Summary

Types

How a property behaves at runtime.

Functions

Resolves component's properties in context.

The behavior of a schema: :dynamic, :action, :structural, :checkable, :static, {:object, shape} or {:array, element}.

Types

behavior()

(since 0.1.0)
@type behavior() ::
  :dynamic
  | :action
  | :structural
  | :checkable
  | :static
  | {:object, %{optional(String.t()) => behavior()}}
  | {:array, behavior()}

How a property behaves at runtime.

Functions

bind(context, component, catalog, options \\ [])

(since 0.1.0)

Resolves component's properties in context.

catalog supplies the component's schema (nil or a catalog without the component falls back to shape inference). Option :schema overrides the component schema.

With wrap: true every dynamic position comes back as an A2UICore.Resolution.Binding (writable when it was bound to a path, read-only for a literal or a call, and a read-only nil binding when the component omitted it) and every action as an A2UICore.Resolution.Action, instead of bare values. The positions are those the schema declares, allOf envelopes included.

classify(schema, defs)

(since 0.1.0)
@spec classify(term(), map()) :: behavior()

The behavior of a schema: :dynamic, :action, :structural, :checkable, :static, {:object, shape} or {:array, element}.

defs are the definitions its $refs resolve against.