Jidoka.Turn.Transition (Jidoka v0.9.0)

Copy Markdown View Source

Pure transition result for turn state changes.

Domain functions can produce state plus neutral events/diagnostics. commit/1 appends those events to the state in sequence order.

Summary

Functions

Commits transition events and diagnostics to the state map.

Adds one diagnostic value to a transition.

Adds one neutral event to a transition.

Starts a pure transition for a state map.

Starts a pure transition and raises if its attributes are invalid.

Returns the Zoi schema for a pure turn transition.

Types

state()

@type state() :: map()

t()

@type t() :: %Jidoka.Turn.Transition{
  diagnostics: [any()],
  events: [term()],
  state: any()
}

Functions

commit(transition)

@spec commit(t()) :: state()

Commits transition events and diagnostics to the state map.

diagnostic(transition, diagnostic)

@spec diagnostic(t(), term()) :: t()

Adds one diagnostic value to a transition.

event(transition, event, attrs \\ [])

@spec event(t(), atom(), keyword() | map()) :: t()

Adds one neutral event to a transition.

new(state, attrs \\ [])

@spec new(state(), keyword() | map()) :: {:ok, t()} | {:error, term()}

Starts a pure transition for a state map.

new!(state, attrs \\ [])

@spec new!(state(), keyword() | map()) :: t()

Starts a pure transition and raises if its attributes are invalid.

schema()

@spec schema() :: Zoi.schema()

Returns the Zoi schema for a pure turn transition.