StateReducer
public protocol StateReducer
Generic State Machine Type
-
Events are effectful inputs from the outside world which the state reacts to, described by some data type. For instance: a button being clicked, or some network data arriving.
Declaration
Swift
associatedtype InputEvent -
Commands are effectful outputs which the state desires to have performed on the outside world. For instance: showing an alert, transitioning to some different UI, etc.
Declaration
Swift
associatedtype OutputCommand -
In response to an event, a state may transition to some new value, and it may emit a command.
Declaration
Swift
mutating func handleEvent(event: InputEvent) -> OutputCommand -
State machines must specify an initial value.
Declaration
Swift
static var initialState: Self { get }