# `Finitomata.Supervisor`
[🔗](https://github.com/am-kantox/finitomata/blob/v0.35.0/lib/finitomata/supervision/supervisor.ex#L1)

THe behaviour for actual _FSM_ implementations across _Finitomata_ framework.

It ships with two predefined implementations, `Finitomata` for local
  applications and `Infinitomata` for distributed ones.

# `t`
*since 0.26.0* 

```elixir
@type t() :: module()
```

The module, implementing this behaviour

# `alive?`
*since 0.26.0* 

```elixir
@callback alive?(id :: Finitomata.id(), fsm_name :: Finitomata.fsm_name()) :: boolean()
```

Returns whether the _FSM_ instance under `id` “branch” and with `fsm_name` name is alive

# `all`
*since 0.26.0* 

```elixir
@callback all(Finitomata.id()) :: %{
  optional(Finitomata.fsm_name()) =&gt; %{
    optional(:node) =&gt; node(),
    optional(:reference) =&gt; reference(),
    optional(:module) =&gt; Finitomata.implementation(),
    pid: pid()
  }
}
```

Returns all the active _FSM_ instances under the `id` “branch,” it might be a heavy map

# `child_spec`
*since 0.26.0* 

```elixir
@callback child_spec(id :: Finitomata.id()) :: Supervisor.child_spec()
```

The `Finitomata` “branch” child specification, used from supervision trees to start supervised _FSM_ “branchs”

# `start_fsm`
*since 0.26.0* 

```elixir
@callback start_fsm(
  id :: Finitomata.id(),
  fsm_name :: Finitomata.fsm_name(),
  implementation :: Finitomata.implementation(),
  payload :: Finitomata.payload()
) :: DynamicSupervisor.on_start_child()
```

Starts the new _FSM_ instance under `id` “branch,” the semantics is similar to `DynamicSupervisor.start_child/2`

# `state`
*since 0.26.0* 

```elixir
@callback state(
  id :: Finitomata.id(),
  fsm_name :: Finitomata.fsm_name(),
  reload? ::
    :cached | :payload | :state | :full | (Finitomata.State.t() -&gt; any())
) :: nil | Finitomata.State.t() | Finitomata.State.payload() | any()
```

Returns the state of the _FSM_ instance under `id` “branch” with `fsm_name` name

# `timer_tick`
*since 0.26.0* 

```elixir
@callback timer_tick(id :: Finitomata.id(), fsm_name :: Finitomata.fsm_name()) :: :ok
```

Effectively initiates the `on_timer/2` callback imminently, resetting the timer

# `transition`
*since 0.26.0* 

```elixir
@callback transition(
  id :: Finitomata.id(),
  fsm_name :: Finitomata.fsm_name(),
  event_payload ::
    Finitomata.Transition.event()
    | {Finitomata.Transition.event(), Finitomata.State.payload()},
  delay :: non_neg_integer()
) :: :ok
```

Sends the event with an optional payload to the running _FSM_ instance to initiate a transition

# `child_spec`
*since 0.26.0* 

Returns a specification to start this module under a supervisor.

See `Supervisor`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
