Search documentation of Plushie

# Plushie.Event.BuiltinSpecs (Plushie v0.7.2)

Copy Markdown View Source

Canonical event specs for all built-in widget event types.

Each spec describes what data the event carries and where it goes:

- `%{carrier: :none}` - no payload (just id/scope)
- `%{carrier: :value, type: type}` - scalar in `WidgetEvent.value`
- `%{carrier: :value, fields: [field: type]}` - map in `WidgetEvent.value`

Type identifiers are either built-in atoms (`:float`, `:string`, `:boolean`, `:any`) or modules implementing `Plushie.Type`.

Used by the canvas widget emit path and the protocol decoder to route event data into the correct WidgetEvent fields with proper parsing.

## Summary

### Types

field_type()

Event field type identifier.

t()

Event spec describing the payload shape.

### Functions

all()

Returns all built-in event specs as a map.

spec(name)

Returns the event spec for a built-in event type, or nil.

## Types

# field_type()

    @type field_type() :: :float | :string | :boolean | :any | module()

Event field type identifier.

Built-in atomic types or a module implementing `Plushie.Type`.

# t()

    @type t() :: %{
      :carrier => :none | :value,
      optional(:doc) => String.t(),
      optional(:type) => field_type(),
      optional(:fields) => [{atom(), field_type()}],
      optional(:required) => [atom()]
    }

Event spec describing the payload shape.

- `:none` - no payload
- `:value` - scalar value, stored in `WidgetEvent.value`
- `:value` with `:fields` - structured map, stored in `WidgetEvent.value` with atom keys

## Functions

# all()

    @spec all() :: %{required(atom()) => t()}

Returns all built-in event specs as a map.

# spec(name)

    @spec spec(name :: atom()) :: t() | nil

Returns the event spec for a built-in event type, or nil.