interaction

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package interaction implements a declarative event→condition→action engine for UISpec interactions. It dispatches events through matching interaction rules, evaluates conditions via the expression evaluator, and executes registered action handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionHandler

type ActionHandler func(ctx context.Context, action uispec.InteractionAction, eventData map[string]any) error

ActionHandler executes a single interaction action.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine routes events through interaction rules and executes actions.

func New

func New(store *state.Store) *Engine

New creates an Engine with built-in handlers (state.set, state.toggle, component.refresh, navigate) wired to the provided state store.

func (*Engine) Dispatch

func (e *Engine) Dispatch(ctx context.Context, interactions []uispec.Interaction, event Event) error

Dispatch finds all interactions matching the event and executes their actions. Actions within a single interaction run sequentially; all matching interactions are evaluated.

func (*Engine) RegisterHandler

func (e *Engine) RegisterHandler(action string, handler ActionHandler)

RegisterHandler adds or replaces a named action handler.

type Event

type Event struct {
	ComponentID string
	EventName   string
	Data        map[string]any
}

Event represents a component event to be dispatched.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL