Flexflow (flexflow v0.1.7) View Source

Usage

defmodule Review do
  use Flexflow.Process, version: 1

  defmodule Reviewing do
    use Flexflow.Event
  end

  defmodule Submit do
    use Flexflow.Transition
  end

  ## Start event
  event {Start, "draft"}
  ## End event, `async` mode means this transition run's in a separated elixir process.
  event {End, "reviewed"}, async: true
  event {End, "canceled"}
  ## Intermediate event
  event "rejected"
  ## Custom event
  event Reviewing

  ## Define a transition
  ## `a ~> b` is a shortcut of `{a, b}`
  transition "modify1", "draft" ~> "draft"
  transition "cancel1", "draft" ~> "canceled"

  ## Custom transition
  transition Submit, "draft" ~> Reviewing

  transition "modify2", "rejected" ~> "rejected"
  transition "cancel2", "rejected" ~> "canceled"

  ## With custom name
  transition {Submit, "submit2"}, "rejected" ~> Reviewing

  transition "reject", Reviewing ~> "rejected"
  transition "agree", Reviewing ~> "reviewed"
end

Link to this section Summary

Link to this section Types

Specs

events() :: %{required(key_normalize()) => Flexflow.Event.t()}

Specs

id() :: String.t()

Specs

key() :: key_normalize() | module()

Specs

key_normalize() :: {module(), name()}

Specs

name() :: String.t()

Specs

process_args() :: map()

Specs

process_identity() :: {module(), id()}

Specs

transitions() :: %{required(key_normalize()) => Flexflow.Transition.t()}

Link to this section Functions