StateMachine.Context (state_machine v0.1.7)

Context is a container for all metadata supporting the transition. Normally users should not have anything to do with Contexts, however some public functions might expose it. For example, user can (but discuraged) manipulate the Context in callbacks.

Summary

Functions

Builds a fresh context based on State Machine definition and a model struct.

Types

t(model)

@type t(model) :: %StateMachine.Context{
  definition: StateMachine.t(model),
  error: any(),
  event: atom(),
  model: model,
  payload: any(),
  status: :init | :failed | :done,
  transition: StateMachine.Transition.t(model) | nil
}

Functions

build(definition, model)

@spec build(StateMachine.t(model), model) :: t(model) when model: var

Builds a fresh context based on State Machine definition and a model struct.