# `Dala.Platform.Settings`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/platform/settings.ex#L1)

Persistent app settings (UserDefaults on iOS, SharedPreferences on Android).

## Examples

    # Get a setting value
    Dala.Platform.Settings.get("theme")

    # Set a setting value
    socket = Dala.Platform.Settings.set(socket, "theme", "dark")

    # Watch a key for changes (messages arrive via handle_info)
    socket = Dala.Platform.Settings.watch(socket, "theme")

Incoming change messages are delivered to screens via `handle_info/2`:

    def handle_info({:settings, :changed, {key, value}}, socket) do
      # React to setting change
      {:noreply, socket}
    end

# `get`

```elixir
@spec get(String.t()) :: any() | nil
```

Get a setting value by key. Returns `nil` if the key is not set.

# `set`

```elixir
@spec set(Dala.Socket.t(), String.t(), any()) :: Dala.Socket.t()
```

Set a setting value. Returns the socket unchanged.

# `watch`

```elixir
@spec watch(Dala.Socket.t(), String.t()) :: Dala.Socket.t()
```

Watch a key for changes. Change notifications arrive as
`{:settings, :changed, {key, value}}` via `handle_info/2`.

Returns the socket unchanged.

---

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