# `Mob.Registry`
[🔗](https://github.com/genericjam/mob/blob/master/lib/mob/registry.ex#L1)

Maps component names (atoms) to their platform-specific NIF constructors.

Each entry maps a component name to a per-platform tuple:
`{nif_module, function_name, extra_args}`.

## Example

    Mob.Registry.register(MyReg, :map_view,
      android: {:mob_nif, :create_map_view, []},
      ios:     {:mob_nif, :create_map_view, []}
    )

    {:ok, {mod, fun, args}} = Mob.Registry.lookup(MyReg, :map_view, :android)
    apply(mod, fun, args)

## Default registry

`Mob.Registry` itself is started by the Mob application and pre-populated
with the built-in component vocabulary. Third-party packages call
`Mob.Registry.register/3` in their `Application.start/2`.

# `all`

```elixir
@spec all(GenServer.server()) :: [atom()]
```

List all registered component names.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `lookup`

```elixir
@spec lookup(GenServer.server(), atom(), atom()) ::
  {:ok, {module(), atom(), list()}} | {:error, :not_found}
```

Look up the NIF spec for a component on a given platform.

Returns `{:ok, {mod, fun, args}}` or `{:error, :not_found}`.

# `register`

```elixir
@spec register(GenServer.server(), atom(), keyword()) :: :ok
```

Register a component name with platform-specific NIF constructors.

`mappings` is a keyword list of `platform: {mod, fun, args}` entries.
Calling register again for an existing name merges/overwrites platforms.

# `start_link`

```elixir
@spec start_link(keyword()) :: Agent.on_start()
```

Start a registry Agent.

Pass `name: nil` for an anonymous registry (useful in tests).
Pass `name: Mob.Registry` for the global application registry.

---

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