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.
Summary
Functions
List all registered component names.
Returns a specification to start this module under a supervisor.
Look up the NIF spec for a component on a given platform.
Register a component name with platform-specific NIF constructors.
Start a registry Agent.
Functions
@spec all(GenServer.server()) :: [atom()]
List all registered component names.
Returns a specification to start this module under a supervisor.
See Supervisor.
@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}.
@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.
@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.