Shout.Router (Shout v0.1.0) View Source

Use this module to setup your subscription module. Add it to your supervision tree, it'll start a simple GenServer and store the subscriptions.

defmodule MyApp.Events do
  use Shout.Router

  subscribe(MyApp.Users.Create, :user_created, to: &MyApp.Emails.welcome_email/1)
end

defmodule MyApp.Service.User do
  use MyApp.Events.Publisher

  def create(...) do
    broadcast(:user_created, %{email: "jon@snow.com"})
  end
end

defmodule MyApp.Emails do
  def welcome_email(%{email: email}) do
    SendEmail.to(email)
  end
end

Link to this section Summary

Link to this section Functions

Link to this macro

subscribe(from, event, opts)

View Source (macro)
Link to this macro

unsubscribe(from, event)

View Source (macro)