GenServer that holds the active theme and notifies the running application on change.
The active theme defaults to Drafter.Theme.dark_theme/0 on startup. Call
set_theme/1 with a theme name string (e.g. "nord") to switch themes at runtime;
the registered app process receives a {:theme_updated, theme} message which
triggers a re-render. Use register_app/1 to associate the app loop PID.
Summary
Functions
Returns a specification to start this module under a supervisor.
The active theme for the calling session.
Register the app loop process to receive {:theme_updated, theme} on each change.
Switch the active theme by name, as Drafter.Theme.get_theme/1 resolves it.
Start a theme manager.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_current_theme() :: Drafter.Theme.t()
The active theme for the calling session.
Resolved through Drafter.Session.Context, so it raises when no theme manager is
reachable.
@spec register_app(pid()) :: :ok
Register the app loop process to receive {:theme_updated, theme} on each change.
Only one process is registered at a time; registering again replaces the previous one. Asynchronous.
@spec set_theme(String.t()) :: :ok
Switch the active theme by name, as Drafter.Theme.get_theme/1 resolves it.
A name no built-in theme matches is silently ignored and the active theme is left
alone. Asynchronous: returns :ok before the switch has happened.
@spec start_link(keyword()) :: GenServer.on_start()
Start a theme manager.
Options
:name- registered name, ornilto start it unnamed for a single session. Default:Drafter.ThemeManager.
Any other options are accepted and ignored; the starting theme is always
Drafter.Theme.dark_theme/0.