Macaw.Frame.Local (macaw_frame v0.1.0)

Copy Markdown View Source

The Frame's :local keys and its adapter for their values on the client bus (spec/01 §5.2), copied from visualize's Visualize.Hooks.Sync: its sync groups are these keys, named by the cell's sync setting, and its bus's domain units are the spelling below. No sync bus is carried over: the bus is macaw_component's (its spec/02 §8.2).

The keys (keys/3): with a group, each frame's model names the keys it takes ("<group>" with the x scale's domain type, "<group>.brush" as :window and "<group>.item" as :identity on a cartesian frame over a :linear or :time x; "<group>.item" alone over any other; "<group>.view" as :box on a geographic frame), and the document's interaction gives the shape: hover unless hover: false, the brush key only with a brush, the view key only with a pan. No group declares no key.

The values (value/2), one spelling every component sharing a key's name shares:

TypeSpelling
:timemilliseconds since the Unix epoch
:numberthe number
:window[lo, hi] in the x scale's units (a time as epoch milliseconds)
:box[west, south, east, north] in degrees
:identityan object of field to scalar, a time field's value as its ISO 8601 spelling in UTC

nil is nil for every type: the key cleared. Nothing on the bus reaches the server; the adapter only fixes what a hook publishes and what the server writes for it to read.

Summary

Functions

The :local keys of a compiled document's realized models (by frame name) under the group sync (§5.2), shaped by the document's interaction: %{key => domain type}, %{} with no group.

The domain types the adapter spells, in order.

A key's value as the bus carries it (§5.2): {:ok, term} JSON holds as it is, or {:error, faults} for a value that is no value of the type ({:type, type} at [1]) and a type the adapter does not spell ({:enum, types} at [0]).

Functions

keys(models, interaction, sync)

@spec keys(map(), map(), String.t() | nil) :: %{required(String.t()) => atom()}

The :local keys of a compiled document's realized models (by frame name) under the group sync (§5.2), shaped by the document's interaction: %{key => domain type}, %{} with no group.

types()

@spec types() :: [atom(), ...]

The domain types the adapter spells, in order.

value(type, time)

@spec value(atom(), term()) :: {:ok, term()} | {:error, [{list(), term()}, ...]}

A key's value as the bus carries it (§5.2): {:ok, term} JSON holds as it is, or {:error, faults} for a value that is no value of the type ({:type, type} at [1]) and a type the adapter does not spell ({:enum, types} at [0]).

iex> Macaw.Frame.Local.value(:time, ~U[1970-01-01 00:00:01Z])
{:ok, 1000}
iex> Macaw.Frame.Local.value(:window, %{from: 2, to: 5})
{:ok, [2, 5]}
iex> Macaw.Frame.Local.value(:identity, %{"host" => "a", "at" => ~U[2026-01-01 00:00:00Z]})
{:ok, %{"at" => "2026-01-01T00:00:00Z", "host" => "a"}}