StateContext is a one of a most important objects when working with a state machine as it is passed into various methods and callbacks to give status of a current state of a state machine and where it is possibly going. If simplifying things a little it can be considered to be a snapshot of a current state machine stage where it is at a time StateContext is passed on.
Note | |
---|---|
In |
In overall StateContext can be used as.
Message
, Event
or their
MessageHeaders
if known.
Extended State
.
StateMachine
itself.
Transition
if applicable.
Stage
as described in Section 17.1, “Stages”.
StateContext is passed into various components interacting with user
like Action
and Guard
.
Stage is representation of a stage
on
which a state machine is currently interacting with a user. Current
stages are EVENT_NOT_ACCEPTED
, EXTENDED_STATE_CHANGED
,
STATE_CHANGED
, STATE_ENTRY
, STATE_EXIT
, STATEMACHINE_ERROR
,
STATEMACHINE_START
, STATEMACHINE_STOP
, TRANSITION
,
TRANSITION_START
and TRANSITION_END
which look very familiar as
those match how user can interact with listeners as described in
Chapter 19, Listening State Machine Events.