Cizen.Automaton behaviour (Cizen v0.17.0) View Source
A saga framework to create an automaton.
Link to this section Summary
Functions
Performs an effect.
Callbacks
Invoked when the automaton is resumed.
Invoked when the automaton is spawned. Saga.Started event will be dispatched after this callback.
Link to this section Types
Specs
finish() :: {Cizen.Automaton, :finish}
Specs
state() :: term()
Link to this section Functions
Link to this section Callbacks
Specs
respawn(Cizen.SagaID.t(), Cizen.Saga.t(), state()) :: finish() | state()
Invoked when the automaton is resumed.
Returned value will be used as the next state to pass yield/2
callback.
Returning Automaton.finish()
will cause the automaton to finish.
This callback is predefined. The default implementation is here:
def respawn(id, saga, state) do
spawn(id, saga)
state
end
Specs
spawn(Cizen.SagaID.t(), Cizen.Saga.t()) :: finish() | state()
Invoked when the automaton is spawned. Saga.Started event will be dispatched after this callback.
Returned value will be used as the next state to pass yield/2
callback.
Returning Automaton.finish()
will cause the automaton to finish.
If not defined, default implementation is used,
and it passes the given saga struct to yield/2
callback.
Specs
yield(Cizen.SagaID.t(), state()) :: finish() | state()
Invoked when last spawn/2
or yield/2
callback returns a next state.
Returned value will be used as the next state to pass yield/2
callback.
Returning Automaton.finish()
will cause the automaton to finish.
If not defined, default implementation is used,
and it returns Automaton.finish()
.