PhoenixKit.Notifications.Events (phoenix_kit v1.7.118)

Copy Markdown View Source

PubSub topic helpers for the notifications feature.

Each recipient has their own topic so broadcasts don't fan out to unrelated LiveViews. Topic shape: "phoenix_kit:notifications:<user_uuid>".

Events sent to these topics:

  • {:notification_created, %Notification{}}
  • {:notification_seen, %Notification{}}
  • {:notification_dismissed, %Notification{}}

Summary

Functions

Broadcasts an event to a user's notification topic. Never raises.

Subscribes the calling process to a user's notification topic.

Returns the per-user PubSub topic.

Unsubscribes the calling process from a user's notification topic.

Functions

broadcast(user_uuid, message)

Broadcasts an event to a user's notification topic. Never raises.

subscribe(user_uuid)

Subscribes the calling process to a user's notification topic.

topic_for_user(user_uuid)

Returns the per-user PubSub topic.

unsubscribe(user_uuid)

Unsubscribes the calling process from a user's notification topic.