How Dyn screens plug into the host's UI: a host seam (config :rho, :dyn, screens: Module, Rho.Dyn.Config). rho builds, checks, selftests and
watches Dyn screens the same way whatever the UI; this says what a
screen is and how the UI tells the Keeper a launch got going:
- compiling: which module bodies are screens (
screen_source?/1) and the function each screen process enters through (entry/0): the compiler wraps it to register the process with the Keeper first (Rho.Dyn.Keeper.watch/3), so the screen's crash counts against its generation; - selftest: which loaded modules are screens (
screen?/1, filed as:screenin the registry,Rho.Dyn.screens/1) and how one proves it mounts and renders (selftest/1, run in the contained selftest process); - launches:
after_first_render/1has the UI call an MFA (with the screen appended) after its first frame, which starts the clock to "stable" (Rho.Dyn.boot/1);subscribe_app_events/0andleft_app?/1: the app lifecycle events the Keeper receives, and which of them mean the user left the app (a launch that drew its first frame and was left is stable, not failed); - the agent's view:
live/1, is generationnon screen yet (sodyn_proposewith approve-all answers once it is);guide/0, the screen rules forRho.Dyn.agent_guide/0.
Rho.Dyn.Screens.None (the default) has no screens; Rho.Dyn.Screens.Mob
is mob's (use Mob.Screen, mount/3 + render/1).
Summary
Callbacks
Has the UI apply mfa (with the screen module appended) after its first frame.
The function a screen process enters through, {name, arity} (mob: {:mount, 3}).
The screen rules for the agent (Rho.Dyn.agent_guide/0), or nil.
Does message (one the Keeper received) mean the user left the app?
Generation n is current: does the UI show it yet (:live), or not yet
(:waiting)? Without this callback, being current is enough (:active).
Is loaded module module a screen?
Do a defmodule's body forms define a screen (its entry gets wrapped)?
Proves screen module works (mounts and renders), in the selftest's
contained process: {:ok, detail} or {:error, why}. A raise is a failure.
Subscribes the calling process (the Keeper) to the app's lifecycle events.
Callbacks
Has the UI apply mfa (with the screen module appended) after its first frame.
The function a screen process enters through, {name, arity} (mob: {:mount, 3}).
@callback guide() :: String.t() | nil
The screen rules for the agent (Rho.Dyn.agent_guide/0), or nil.
Does message (one the Keeper received) mean the user left the app?
@callback live(n :: pos_integer()) :: :live | :waiting
Generation n is current: does the UI show it yet (:live), or not yet
(:waiting)? Without this callback, being current is enough (:active).
Is loaded module module a screen?
Do a defmodule's body forms define a screen (its entry gets wrapped)?
Proves screen module works (mounts and renders), in the selftest's
contained process: {:ok, detail} or {:error, why}. A raise is a failure.
@callback subscribe_app_events() :: :ok
Subscribes the calling process (the Keeper) to the app's lifecycle events.