View Source Protean.State (Protean v0.0.1)

The Protean machine state.

A %Protean.State{} struct encompasses the current state of a machine, including its state configuration (value), the event that triggered a transition to this state, the current context (extended state), and other private state used internally by Protean.

Additionally, the action callback c:pure/3 receives and returns state to update the context and schedule side-effects. See Protean.Action.

Link to this section Summary

Functions

Assign data to a state's context.

TODO: Descriptor usage

Link to this section Types

@type context() :: %{required(any()) => any()}
Link to this opaque

private_state()

View Source (opaque)
@opaque private_state()
@type t() :: %Protean.State{
  context: context(),
  event: Protean.event() | nil,
  private: private_state(),
  value: value()
}
@type value() :: MapSet.t(Protean.Node.id())

Link to this section Functions

@spec assign(t(), %{required(any()) => any()}) :: t()
@spec assign(t(), Enumerable.t()) :: t()
Link to this function

assign(state, key, value)

View Source
@spec assign(t(), any(), any()) :: t()

Assign data to a state's context.

Usage:

  • assign(state, key, value) - Assigns value to key in state's context.
  • assign(state, %{}) - Merges the update map into a state's context.
  • assign(state, enumerable) - Collects the key/values of enumerable into a map, then merges that map into the state's context.
Link to this function

matches?(state, descriptor)

View Source
@spec matches?(t(), Protean.Node.id()) :: boolean()
@spec matches?(t(), String.t()) :: boolean()
@spec matches?(t(), atom()) :: boolean()

TODO: Descriptor usage