Jido.Signal.Registry (Jido v1.1.0-rc.2)
View SourceRegistry for managing signal subscriptions.
Provides functionality to register, unregister, and manage subscriptions to signal paths with associated dispatch configurations.
Summary
Functions
Returns a list of all subscriptions in the registry.
Returns the count of subscriptions in the registry.
Returns all subscriptions for a given path pattern.
Looks up a subscription by its ID.
Creates a new empty registry.
Registers a new subscription in the registry.
Unregisters a subscription from the registry.
Types
@type t() :: %Jido.Signal.Registry{ subscriptions: %{ required(String.t()) => Jido.Signal.Registry.Subscription.t() } }
Registry containing a unique mapping of subscription IDs to subscriptions
Functions
@spec all(t()) :: [Jido.Signal.Registry.Subscription.t()]
Returns a list of all subscriptions in the registry.
@spec count(t()) :: non_neg_integer()
Returns the count of subscriptions in the registry.
@spec find_by_path(t(), String.t()) :: [Jido.Signal.Registry.Subscription.t()]
Returns all subscriptions for a given path pattern.
Finds all subscriptions that would match the given signal path.
@spec lookup(t(), String.t()) :: {:ok, Jido.Signal.Registry.Subscription.t()} | {:error, :not_found}
Looks up a subscription by its ID.
Returns
{:ok, subscription}
- Subscription was found{:error, :not_found}
- No subscription with this ID exists
Creates a new empty registry.
Examples
iex> registry = Jido.Signal.Registry.new()
Registers a new subscription in the registry.
Parameters
- registry - The current registry
- id - Unique identifier for the subscription
- path - Signal path pattern to subscribe to
- dispatch - Dispatch configuration for matched signals
Returns
{:ok, updated_registry}
- Subscription was added successfully{:error, :already_exists}
- A subscription with this ID already exists
Examples
iex> {:ok, registry} = Registry.register(registry, "sub1", "user.created", dispatch_config)
Unregisters a subscription from the registry.
Parameters
- registry - The current registry
- id - ID of the subscription to remove
Returns
{:ok, updated_registry}
- Subscription was removed successfully{:error, :not_found}
- No subscription with this ID exists
Examples
iex> {:ok, registry} = Registry.unregister(registry, "sub1")