# `Concord.Sync.WatchHub`
[🔗](https://github.com/gsmlg-dev/concord/blob/main/lib/concord/sync/watch_hub.ex#L1)

Registry-based subscriber management for Concord's watch protocol.

Watchers register with a selector (key, prefix, or range) and receive
matching events pushed to their mailbox. Supports bounded delivery queues
with backpressure.

## Usage

    {:ok, watch_ref} = Concord.Sync.WatchHub.subscribe({:prefix, "/tasks/"}, self())

    receive do
      {:concord_event, ^watch_ref, event} -> handle(event)
    end

    :ok = Concord.Sync.WatchHub.unsubscribe(watch_ref)

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `count`

```elixir
@spec count() :: non_neg_integer()
```

Returns the count of active watchers.

# `notify`

```elixir
@spec notify([Concord.Sync.Event.t()]) :: :ok
```

Delivers matching events to all registered watchers.
Called by the Dispatcher.

# `start_link`

# `subscribe`

```elixir
@spec subscribe(Concord.KV.Selector.t(), pid(), keyword()) ::
  {:ok, reference()} | {:error, term()}
```

Subscribes a process to events matching the given selector.

Returns `{:ok, watch_ref}` where `watch_ref` is a unique reference.

# `unsubscribe`

```elixir
@spec unsubscribe(reference()) :: :ok
```

Unsubscribes a watch by its reference.

