Skip to content

Latest commit

 

History

History
118 lines (66 loc) · 2.63 KB

DSL-Ash.Signals.md

File metadata and controls

118 lines (66 loc) · 2.63 KB

Ash.Signals

signals

Declare signals that resources can emit and listen to.

Nested DSLs

Examples

signals do
  signal :post_created do
    argument :post_id, :uuid, allow_nil?: false
  end
end

signals.signal

signal name

Declares a signal, and defines a struct for its arguments.

For a signal named :post_created in MyApp.Signals, this is MyApp.Signals.PostCreated.

Nested DSLs

Examples

signal :post_created do
  argument :post_id, :uuid, allow_nil?: false
end

Arguments

Name Type Default Docs
name{: #signals-signal-name .spark-required} atom The name of the signal.

Options

Name Type Default Docs
phase{: #signals-signal-phase } :before_action | :after_action | :after_transaction :after_action The phase of the emitting action during which the signal may be emitted.
description{: #signals-signal-description } String.t A description of the signal.

signals.signal.argument

argument name, type

An argument of the signal, provided by the emitter.

Examples

argument :post_id, :uuid, allow_nil?: false

Arguments

Name Type Default Docs
name{: #signals-signal-argument-name .spark-required} atom The name of the field.
type{: #signals-signal-argument-type .spark-required} module The type of the field.

Options

Name Type Default Docs
constraints{: #signals-signal-argument-constraints } keyword [] Constraints for the type.
allow_nil?{: #signals-signal-argument-allow_nil? } boolean true Whether the field may be nil.
default{: #signals-signal-argument-default } any A default value for the field.
description{: #signals-signal-argument-description } String.t A description of the field.

Introspection

Target: Ash.Signals.Field

Introspection

Target: Ash.Signals.Signal

<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>