# `Drafter.ThemeManager`
[🔗](https://github.com/jaman/drafter/blob/main/lib/drafter/theming/theme_manager.ex#L1)

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.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `get_current_theme`

```elixir
@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.

# `register_app`

```elixir
@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.

# `set_theme`

```elixir
@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.

# `start_link`

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

Start a theme manager.

## Options

  * `:name` - registered name, or `nil` to 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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
