Macaw.Component.Declarations (macaw_component v0.1.2)

Copy Markdown View Source

A component's configured declarations (spec/01 §1.2), built by new/2 from its declarations/1 answer, every key checked, every fault at once.

No atom is made from a name: names are strings, and an observation spelled as a string is matched against the vocabulary's atoms.

Summary

Functions

Whether the declarations name an event.

The keys, in the order of spec/01 §1.2's table.

The declarations from an answer (a keyword list or a map with atom keys) for a component module, which isolation: :contained is checked against.

Types

t()

@type t() :: %Macaw.Component.Declarations{
  access: String.t() | nil,
  announces: [String.t()],
  events: [String.t()],
  isolation: :pure | :contained,
  local: %{required(String.t()) => Macaw.Component.State.type()},
  observes: [atom()],
  proxy_routes: [Macaw.Component.Proxy.route()],
  reading: :glance | :scan | :read,
  shortcuts: [%{key: String.t(), action: String.t(), description: String.t()}],
  slots: %{required(String.t()) => Macaw.Component.Slot.t()},
  stylesheets: [String.t()],
  words: non_neg_integer() | nil,
  writes: %{required(String.t()) => Macaw.Component.State.type()}
}

Functions

emits?(declarations, name)

@spec emits?(t(), String.t()) :: boolean()

Whether the declarations name an event.

keys()

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

The keys, in the order of spec/01 §1.2's table.

new(answer, module)

@spec new(keyword() | map(), module() | nil) ::
  {:ok, t()} | {:error, [Macaw.Component.fault(), ...]}

The declarations from an answer (a keyword list or a map with atom keys) for a component module, which isolation: :contained is checked against.

iex> {:ok, d} = Macaw.Component.Declarations.new([events: ["open"], reading: :scan], nil)
iex> {d.events, d.reading, d.isolation}
{["open"], :scan, :pure}