Jido.Signal.Bus.Subscriber (Jido Signal v1.0.0)

View Source

Defines the subscriber model and subscription management for the signal bus.

This module contains the subscriber type definition and functions for creating, managing, and dispatching signals to subscribers. It supports both regular and persistent subscriptions, handling subscription lifetime and signal delivery.

Summary

Types

t()

@type t() :: %Jido.Signal.Bus.Subscriber{
  created_at: DateTime.t(),
  disconnected?: boolean(),
  dispatch: term(),
  id: String.t(),
  path: String.t(),
  persistence_pid: pid(),
  persistent?: boolean()
}

Functions

dbug(_, _ \\ [])

(macro)

error(_, _ \\ [])

(macro)

subscribe(state, subscription_id, path, opts)

@spec subscribe(Jido.Signal.Bus.State.t(), String.t(), String.t(), keyword()) ::
  {:ok, Jido.Signal.Bus.State.t()} | {:error, Jido.Signal.Error.t()}

unsubscribe(state, subscription_id, opts \\ [])

@spec unsubscribe(Jido.Signal.Bus.State.t(), String.t(), keyword()) ::
  {:ok, Jido.Signal.Bus.State.t()} | {:error, Jido.Signal.Error.t()}

Unsubscribes from the bus by removing the subscription and cleaning up resources.

For persistent subscriptions, this also terminates the associated process.

Parameters

  • state: The current bus state
  • subscription_id: The unique identifier of the subscription to remove
  • opts: Additional options (currently unused)

Returns

  • {:ok, new_state} if successful
  • {:error, Error.t()} if the subscription doesn't exist or removal fails