# `EventBroker.Registry`

I am the Registry for the PubSub system.

I am the central registry of all the topic subscriptions and filters. I am
responsible for spawning filter agents, (un)subscribing to them, and keeping
track of relations between them.

## Subscriptions

When a process with pid `p` subscribes to a filter spec `[f, g]`, a  "filter
agent" will be spawned for both `f` and `g`.

A filter agent is a process that receives events, and only forwards the events
that match its filter.

If a filter spec list is subscribed to for which any prefix already has an
existing filter agent, these are not spawned. The existing filter agents will
be used instead.

## Registered Filters

When a process subscribes to a filter spec list,

# `registered_filters`

```elixir
@type registered_filters() :: %{required(EventBroker.filter_spec_list()) =&gt; pid()}
```

# `registered_subscribers`

```elixir
@type registered_subscribers() :: %{
  required(pid()) =&gt; [EventBroker.filter_spec_list()]
}
```

I am the type of the registered subscribers. I map a subscriber pid to all
their filter specs.

# `t`

```elixir
@type t() :: %EventBroker.Registry{
  registered_filters: registered_filters(),
  registered_subscribers: registered_subscribers(),
  supervisor: atom()
}
```

I am the type of the Registry.

My main functionality is to keep track of all spawned filter actors.

### Fields

- `:supervisor` - The name of the dynamic supervisor launched on start.
- `:registered_filters` - The map whose keys are a filter-spec dependency
list and whose values are PID's of filter
agents corresponding to said lists.
- `:registered_subscribers` - The map whose keys are a subscriber PID mapped onto their filter specs.
Default: %{}

# `__struct__`
*struct* 

I am the type of the registered filters, matching a filter agent to its
PID.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

```elixir
@spec start_link(list()) :: GenServer.on_start()
```

---

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