fsmx v0.1.0 Fsmx.Fsm behaviour View Source

Holds transition and callback logic for finite state machines

By default, when using use Fsmx.Struct, this is automatically included as well. Specifying use Fsmx.Struct, fsm: MyApp.Fsm allows you to decouple this, though

defmodule MyApp.Struct do
  defstruct [:state]
end

defmodule MyApp.Fsm do
  use Fsmx.Fsm, transitions: %{}

  def before_transition(struct, _from, _to) do
    # ...
  end
end

Link to this section Summary

Link to this section Callbacks

Link to this callback

after_transition_multi(struct, binary, binary)

View Source

Specs

after_transition_multi(struct(), binary(), binary()) ::
  {:ok, struct()} | {:error, any()}
Link to this callback

before_transition(struct, binary, binary)

View Source

Specs

before_transition(struct(), binary(), binary()) ::
  {:ok, struct()} | {:error, any()}
Link to this callback

transition_changeset(struct, binary, binary)

View Source

Specs

transition_changeset(struct(), binary(), binary()) ::
  {:ok, Ecto.Changeset.t()} | {:error, any()}