class UI::ActionDispatcher

Overview

Per-app coordinator that translates UI actions into navigation operations or inline view renders.

Defined in:

asset_pipeline/action_dispatcher.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(app : UI::App.class, navigation : UI::NavigationCoordinator, session : UI::Session, flash : UI::Flash, design_tokens : UI::DesignTokens::Tokens) #

[View source]

Instance Method Detail

def app : UI::App.class #

[View source]
def current_form_state : UI::FormState #

[View source]
def current_mount_token : Int64 #

Monotonically-increasing mount token. The dispatcher writes this to UI::FormState.current_mount_token on every screen mount so the renderer's stale-callback guard fires correctly.


[View source]
def design_tokens : UI::DesignTokens::Tokens #

[View source]
def dispatch(action_ref : Symbol | Tuple(UI::Controller.class, Symbol), explicit_params : Hash(String, String) = {} of String => String) : Nil #

Resolve + dispatch an action_ref. Builds a fresh Native context with the dispatcher's current FormState + the explicit params from the action_ref's button. Runs before_actions on the resolved controller class; if any returns a UI::ActionResult, the dispatch short-circuits. Otherwise calls dispatch_action and translates the returned result via translate_result.


[View source]
def flash : UI::Flash #

[View source]
def mount_screen(route : UI::NavigationCoordinator::Route) : Nil #

Called when a new screen mounts. Increments the mount token AND creates a new FormState carrying that token. Renderer callbacks captured under the prior token become no-ops (Codex finding #3).

Initial form-state values are seeded from the route's params hash (e.g. a :detail route's :id => "42" ends up as form_state["id"] == "42") — convenient for screens that need to know which row they're showing without the controller pre-pop'ing.

The route argument is the route being mounted. The caller is responsible for ensuring that this matches what the coordinator will publish (the dispatcher's internal translate_result does mount-then-notify to guarantee the renderer's wire-time read of UI::FormState.current sees the NEW mount).


[View source]
def mount_screen(route_id : Symbol) : Nil #

Convenience overload that resolves the route from the coordinator (the route_id is asserted to match the coord's current route). Useful for #mount_screen(route_id) callers that have already pushed the route onto the coord and want to mount based on it.


[View source]
def navigation : UI::NavigationCoordinator #

[View source]
def on_render_inline : Proc(UI::View, Nil) | Nil #

Optional callback for UI::ActionResult::RenderInline results. The host (macOS / iOS) wires this on startup to present the inline view (e.g. sheet, popover) without disturbing the navigation stack.


[View source]
def on_render_inline=(on_render_inline : Proc(UI::View, Nil) | Nil) #

Optional callback for UI::ActionResult::RenderInline results. The host (macOS / iOS) wires this on startup to present the inline view (e.g. sheet, popover) without disturbing the navigation stack.


[View source]
def session : UI::Session #

[View source]