Aurora.Uix.Action (Aurora UIX v0.1.0)

Represents an action with a name and an associated function component.

Key Features

  • Encapsulates an action's name and its function component.
  • Provides flexible constructors for different input types.

Key Constraints

  • The :name must be a binary.
  • The :function_component must be a function.

Summary

Functions

Retrieves all the available actions group.

Retrieves the available actions for the given group.

Creates a new action from a tuple containing the name and function component.

Creates a new action from a name and a function component.

Types

t()

@type t() :: %Aurora.Uix.Action{function_component: function(), name: binary()}

Functions

action_groups()

@spec action_groups() :: [atom()]

Retrieves all the available actions group.

Returns

A list(atom()) with all the available actions groups.

available_actions(action_group)

@spec available_actions(atom()) :: map()

Retrieves the available actions for the given group.

Parameters

  • action_group (atom()) - Name of the group to retrieve.

Returns

A map() or nil if the group does not exists.

new(arg)

@spec new({binary(), function()}) :: t()

Creates a new action from a tuple containing the name and function component.

Parameters

  • {name, function_component} ({binary(), function()}) - Tuple with the action name and function.

Returns

Aurora.Uix.Action.t() - An action struct with the given name and function component.

Examples

iex> Aurora.Uix.Action.new({"delete", fn -> :deleted end})
%Aurora.Uix.Action{name: "delete", function_component: #Function<...>}

new(name, function_component)

@spec new(atom(), function()) :: t()

Creates a new action from a name and a function component.

Parameters

  • name (atom()) - The name of the action.
  • function_component (function()) - The function component to associate.

Returns

Aurora.Uix.Action.t() - An action struct with the given name and function component.

Examples

iex> Aurora.Uix.Action.new("save", fn -> :ok end)
%Aurora.Uix.Action{name: "save", function_component: #Function<...>}