mix compile.ash_signals (ash v3.36.0)

Copy Markdown View Source

Consolidates Ash.Signals listeners, once all modules have been compiled.

Add it to your mix.exs:

compilers: [:ash_signals] ++ Mix.compilers()

If you use the Phoenix code reloader, add it to your endpoint's reloadable compilers too, so that listeners added in development are picked up:

reloadable_compilers: [:ash_signals, :phoenix_live_view, :gettext, :elixir, :app]

Consolidation

Like protocol consolidation, this finds the listeners of each signal module once per build, and compiles them into an Ash.Signals.Dispatch.<SignalModule> module in your application's build directory, so that emitting a signal does not have to search for listeners.

Listeners defined after compilation, like resources defined inside tests, are not part of the consolidated modules. To use them, disable consolidation in your project:

def project do
  [
    ...,
    ash: [consolidate_signals: Mix.env() != :test]
  ]
end

Without consolidation, listeners are searched for every time a signal is emitted.