Search documentation of phoenix_kit

# PhoenixKit.Users.ScopeNotifier (phoenix_kit v1.7.87)

Copy Markdown View Source

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.

## Summary

### Functions

broadcast_roles_updated(user_uuid)

Broadcasts a scope refresh notification for the given user.

subscribe(user_uuid)

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

unsubscribe(user_uuid)

Unsubscribes the current process from scope refresh notifications.

## Functions

# broadcast_roles_updated(user_uuid)

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

Broadcasts a scope refresh notification for the given user.

# subscribe(user_uuid)

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

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

# unsubscribe(user_uuid)

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

Unsubscribes the current process from scope refresh notifications.