A one-shot decision point that runs once, with no screen shown to the caller, and resolves to the next module in the flow.
Useful when the next state can't be expressed as a static transition/2 - e.g. it
depends on an HTTP call or a database lookup:
defmodule MyApp.Actions.LoadAccount do
@behaviour Ussd.Action
@impl Ussd.Action
def execute(context) do
case Accounts.find(Ussd.Context.get(context, :phone)) do
{:ok, _account} -> MyApp.States.Dashboard
:error -> MyApp.States.Registration
end
end
endThe engine keeps calling execute/1 while the result is itself an Ussd.Action,
so actions can chain, and stops once it reaches a real Ussd.State.
Summary
Callbacks
Resolves the next module in the flow: another Ussd.Action to keep chaining, or a Ussd.State to render.
Callbacks
@callback execute(Ussd.Context.t()) :: module()
Resolves the next module in the flow: another Ussd.Action to keep chaining, or a Ussd.State to render.