Jido.Flow.Extension behaviour (Jido Action v3.0.0-beta.12)

View Source

Defines compile-time macro extensions for the Flow module DSL.

An extension adds authoring macros to flow do. Each macro must expand to normal Flow declarations. It does not add a component type, change the canonical %Jido.Flow{} value, or add runtime behavior.

defmodule MyApp.Flows.Helpers do
  use Jido.Flow.Extension

  defmacro notify(name, address) do
    quote do
      step unquote(name),
        action: MyApp.Actions.Notify,
        params: %{address: unquote(address)}
    end
  end
end

defmodule MyApp.Flows.Welcome do
  use Jido.Flow,
    name: "welcome",
    extensions: [MyApp.Flows.Helpers]

  flow do
    notify "welcome", input(:address)
    output result("welcome")
  end
end

Extension macros run during normal Flow compilation. The expanded core declarations keep the usual validation, source mapping, inline Action, and execution rules. Extension modules must be available at compile time.

Only the module DSL loads extensions. Map-based definitions and direct construction use normal Elixir functions that create canonical Flow data. Codec documents contain data only and never load or run an extension. Keep the public API of an extension module limited to macros. Put data definition helpers in another module.

Summary

Functions

Installs the Flow extension contract and imports this module into configured Flows.

Functions

__using__(options)

(macro)
@spec __using__(keyword()) :: Macro.t()

Installs the Flow extension contract and imports this module into configured Flows.