# `Soundcheck.Check.Warning.SubscribedWithoutHandleInfo`
[🔗](https://github.com/leonqadirie/soundcheck/blob/v0.1.0/lib/soundcheck/check/warning/subscribed_without_handle_info.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `high` and works with any version of Elixir.

## Explanation

Flags LiveViews that subscribe to PubSub in `mount/3` but define no
`handle_info/2` at all. The first broadcast on the topic crashes the
LiveView.

Before:

    def mount(_params, _session, socket) do
      if connected?(socket), do: Phoenix.PubSub.subscribe(MyApp.PubSub, "posts")
      {:ok, socket}
    end

After:

    def handle_info({:post_created, post}, socket),
      do: {:noreply, stream_insert(socket, :posts, post)}

Subscriptions match `subscribe_functions` by alias-expanded name, as
in `UnguardedSubscribe`. A `handle_info/2` injected by a `use` macro
counts, because the check reads the compiled module; a handler
attached with `attach_hook/4` silences it.

Confidence: high. Tier: semantic (run `mix compile` before `mix credo`).

## Check-Specific Parameters

Use the following parameters to configure this check:

### `:excluded_paths`

  Paths to skip (atoms, binaries as path segments, or regexes).

*This parameter defaults to* `[~r/\/test\//, "test"]`.

### `:strict`

  Unused.

*This parameter defaults to* `false`.

### `:subscribe_functions`

  Regexes or exact names of subscribing functions, as `Module.function`.

*This parameter defaults to* `[~r/^Phoenix\.PubSub\.subscribe$/, ~r/\.subscribe$/]`.

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

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