TermUI.Event.Propagation (TermUI v1.0.0)
View SourceEvent propagation utilities for the component tree.
Handles bubbling and capturing phases of event propagation. Events bubble up from target to root until handled.
This utility operates on mounted ComponentServer processes registered in
the standalone ComponentRegistry. TermUI.Runtime does not call it; the
1.0 Elm runtime sends events only to its root module.
Propagation Phases
- Capture - Event travels from root to target (optional)
- Target - Event delivered to target component
- Bubble - Event travels from target to root (default)
Usage
# Propagate event up through parent chain
Propagation.bubble(event, component_id)
# Build parent chain for propagation
parents = Propagation.get_parent_chain(component_id)
Summary
Functions
Bubbles an event up through the parent chain.
Captures an event down through the parent chain to target.
Gets children of a component.
Gets the parent chain for a component.
Sets the parent for a component.
Checks if an event should stop propagating.
Adds metadata about propagation phase to event.
Types
Functions
@spec bubble(term(), term(), keyword()) :: propagation_result()
Bubbles an event up through the parent chain.
Starts from the given component and propagates up to parents until a component handles the event or the root is reached.
Parameters
event- The event to propagatestart_id- Component to start bubbling fromopts- Options::skip_start- Skip the starting component (default: false)
Returns
:handled- A component handled the event:unhandled- No component handled the event
@spec capture(term(), term()) :: propagation_result()
Captures an event down through the parent chain to target.
Starts from the root and propagates down to the target component. Each component can intercept before reaching target.
Parameters
event- The event to propagatetarget_id- Target component
Returns
:handled- A component handled the event:unhandled- No component handled the event
Gets children of a component.
Returns
List of child component ids.
Gets the parent chain for a component.
Returns list of parent component ids from immediate parent to root.
Example
# If component tree is: root -> container -> button
get_parent_chain(:button)
# => [:container, :root]
Sets the parent for a component.
Used to build the component tree for propagation.
Parameters
component_id- Child componentparent_id- Parent component (or nil for root)
Checks if an event should stop propagating.
Events can be marked to stop propagation by returning
:stop from handle_event.
Adds metadata about propagation phase to event.
Parameters
event- The eventphase- Current propagation phase
Returns
Event with :propagation_phase metadata.