phoenix-pubsub-patterns

Installation
SKILL.md

Phoenix PubSub Patterns

Use this skill before writing ANY PubSub or real-time broadcast code.

Implementation Workflow

  1. Subscribe in mount — guard with if connected?(socket) to prevent duplicate subscriptions
  2. Broadcast from context — add a private broadcast/2 helper that fires only on {:ok, result}
  3. Handle in handle_info/2 — update assigns immutably with update/3
  4. Verify with a test — call the context function and assert the LiveView reflects the change

Subscription Pattern

defmodule MyAppWeb.PostLive.Index do
  use MyAppWeb, :live_view
Installs
3
First Seen
3 days ago
phoenix-pubsub-patterns — igmarin/elixir-phoenix-skills