Sea v0.5.0 Sea.SignalRouter View Source

Defines project-wide convention for routing Sea signals to nested observers.

Usage

For single observer:

defmodule MyApp.Sales.InvoiceCreatedSignal do
  use Sea.Signal

  emit_to MyApp.Inventory

  # ...
end

defmodule MyApp.Inventory do
  use Sea.SignalRouter, :single_observer

  # ...
end

defmodule MyApp.Inventory.Observer do
  use Sea.Observer

  # example of catching multiple signals to trigger the same operation
  def handle_signal(signal = %{__struct__: struct}) when struct in [
    MyApp.Sales.InvoiceCreatedSignal
  ] do
    MyApp.Inventory.UpdateStatsService.call()
  end
end

Link to this section Summary

Functions

Routes incoming signals to nested observers (separate ones for each incoming signal)

Routes incoming signals to nested observer (single one for all incoming signals)

Link to this section Functions

Link to this function one_signal_one_observer() View Source

Routes incoming signals to nested observers (separate ones for each incoming signal).

Routes incoming signals to nested observer (single one for all incoming signals).