# `Macaw.Live.Notify`
[🔗](https://github.com/dcoai/macaw_live/blob/v0.1.0/lib/macaw/live/notify.ex#L1)

The notification transport (spec/03 §7), a behavior over an argument
([macaw 00 goal 3](https://github.com/dcoai/macaw/blob/main/spec/00-overview.md#overview-goals)):
how a page hears "this source's data changed; re-read it", and how the runtime's own
broadcasts travel.

  * `Macaw.Live.Notify.Local`, the default, reaches this node only, through the
    supervisor's `Registry` of duplicate keys (`<live>.Topics`);
  * `Macaw.Live.Notify.PubSub` takes a `Phoenix.PubSub` name and reaches every node the
    host's PubSub does.

A host chooses it with the supervisor's `notify:` option, `{module, arg}`. **Topics are
prefixed by the supervisor's name,** so two hosts sharing a PubSub never hear each other:
`"macaw:<live>:source:<name>"` and `"macaw:<live>:shared:<digest>"` (`topic/3`). Each
source manager (macaw_data's `Macaw.Data.Manager`) subscribes, when it starts, to the
topic of its source's name (spec/03 §7); a notification is `{:macaw_data, :changed,
name, what}` on it, `what` a change notice's (`Macaw.Live.notify/3`).

# `broadcast`

```elixir
@callback broadcast(arg :: term(), topic :: String.t(), message :: term()) ::
  :ok | {:error, term()}
```

Sends `message` to every process subscribed to `topic`.

# `subscribe`

```elixir
@callback subscribe(arg :: term(), topic :: String.t()) :: :ok | {:error, term()}
```

Subscribes the calling process to `topic`.

# `unsubscribe`

```elixir
@callback unsubscribe(arg :: term(), topic :: String.t()) :: :ok
```

Unsubscribes the calling process from `topic`.

# `topic`

```elixir
@spec topic(atom(), :source | :shared, String.t()) :: String.t()
```

A topic of the supervisor `live`, by kind (`:source` or `:shared`) and name.

    iex> Macaw.Live.Notify.topic(MyApp.Macaw, :source, "services")
    "macaw:MyApp.Macaw:source:services"

---

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