Dala.Screen.Manager (dala v0.3.2)

Copy Markdown View Source

Central registry for tracking all active screens in the application.

Screens auto-register when started and can be queried by id, name, or pid. Monitors registered screens so crashed processes are cleaned up automatically.

Summary

Functions

Returns a specification to start this module under a supervisor.

Sends a message to a screen identified by identifier (id, name, or pid).

Lists all registered screens as a list of maps with :id, :name, :pid, :module.

Generates a unique screen ID.

Registers a screen with the registry.

Starts the screen manager (supervision child spec).

Unregisters a screen by its PID (called when screen stops).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

dispatch(identifier, message)

@spec dispatch(pid() | atom() | integer(), term()) :: :ok | {:error, :not_found}

Sends a message to a screen identified by identifier (id, name, or pid).

Returns :ok if sent, {:error, :not_found} if identifier doesn't match any screen.

list()

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

Lists all registered screens as a list of maps with :id, :name, :pid, :module.

next_id()

@spec next_id() :: integer()

Generates a unique screen ID.

register(id, name, pid, module)

@spec register(integer(), atom() | nil, pid(), module()) :: :ok

Registers a screen with the registry.

  • id: auto-generated unique integer ID
  • name: optional screen name (atom or nil)
  • pid: screen process PID
  • module: screen module (e.g., MyApp.HomeScreen)

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts the screen manager (supervision child spec).

unregister(pid)

@spec unregister(pid()) :: :ok

Unregisters a screen by its PID (called when screen stops).