# `PhoenixKit.Users.ScopeNotifier`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.164/lib/phoenix_kit/users/scope_notifier.ex#L1)

Handles PubSub notifications for user scope refreshes.

When a user's roles change, we broadcast a message on a user-specific topic
so any connected LiveViews can refresh their cached authentication scope
without requiring a full reconnect.

# `broadcast_roles_updated`

```elixir
@spec broadcast_roles_updated(PhoenixKit.Users.Auth.User.t() | binary() | nil) :: :ok
```

Broadcasts a scope refresh notification for the given user.

# `subscribe`

```elixir
@spec subscribe(PhoenixKit.Users.Auth.User.t() | binary()) :: :ok | {:error, term()}
```

Subscribes the current process to scope refresh notifications for the user.

# `unsubscribe`

```elixir
@spec unsubscribe(PhoenixKit.Users.Auth.User.t() | binary() | nil) :: :ok
```

Unsubscribes the current process from scope refresh notifications.

---

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