Dala.Screen (dala v0.6.0)

Copy Markdown View Source

Behaviour and macros for Dala screens.

This module delegates to Dala.Screen.Screen for screen functionality.

Summary

Functions

Defines a screen module.

Dispatch a UI event to the screen process. Returns :ok synchronously once the event has been processed and the state updated.

Return the module of the currently active screen in the navigation stack. Intended for testing and debugging.

Return the navigation history (list of {module, socket} pairs, head = most recent). Intended for testing and debugging.

Return the current socket state of a running screen. Intended for testing and debugging — not for production app logic.

List all registered screens.

Start a screen process linked to the calling process.

Start a screen as the root UI screen. Calls mount, renders the component tree via Dala.Ui.Renderer, and calls set_root_binary on the resulting view.

Functions

__using__(opts)

(macro)

Defines a screen module.

dispatch(pid, event, params)

@spec dispatch(pid(), String.t(), map()) :: :ok

Dispatch a UI event to the screen process. Returns :ok synchronously once the event has been processed and the state updated.

get_current_module(pid)

@spec get_current_module(pid()) :: module()

Return the module of the currently active screen in the navigation stack. Intended for testing and debugging.

get_nav_history(pid)

@spec get_nav_history(pid()) :: [{module(), Dala.Socket.t()}]

Return the navigation history (list of {module, socket} pairs, head = most recent). Intended for testing and debugging.

get_socket(pid)

@spec get_socket(pid()) :: any()

Return the current socket state of a running screen. Intended for testing and debugging — not for production app logic.

list()

@spec list() :: [%{id: integer(), name: atom() | nil, pid: pid(), module: module()}]

List all registered screens.

Returns a list of maps with :id, :name, :pid, :module.

start_link(screen_module, params, opts \\ [])

@spec start_link(module(), map(), keyword()) :: GenServer.on_start()

Start a screen process linked to the calling process.

params is passed as the first argument to mount/3.

start_root(screen_module, params \\ %{}, opts \\ [])

@spec start_root(module(), map(), keyword()) :: GenServer.on_start()

Start a screen as the root UI screen. Calls mount, renders the component tree via Dala.Ui.Renderer, and calls set_root_binary on the resulting view.

This is the main entry point for production use. start_link/3 is for tests (no NIF calls).