Cizen.Effect behaviour (Cizen v0.18.1) View Source

The effect behaviour.

Example

defmodule Repeat do
  use Cizen.Effect
  use Cizen.Effects, only: [Chain]
  defstruct [:count, :effect, :pid]
  @impl true
  def expand(id, %__MODULE__{count: count, effect: effect, pid: pid}) do
    effects =
      [effect]
      |> Stream.cycle()
      |> Enum.take(count)

    %Chain{
      effects: effects
    }
  end
end

Link to this section Summary

Link to this section Types

Specs

alias_of() :: {:alias_of, t()}

Specs

consume() :: {:consume, term()}

Specs

handler() :: Cizen.SagaID.t()

Specs

resolve() :: {:resolve, term()}

Specs

t() :: struct()

Link to this section Functions

Link to this function

handle_event(handler, event, effect, state)

View Source

Specs

handle_event(handler(), Cizen.Event.t(), t(), state :: term()) ::
  resolve() | consume() | term()

Specs

init(handler(), t()) :: resolve() | {t(), term()}

Link to this section Callbacks

Specs

expand(handler(), t()) :: t()
Link to this callback

handle_event(handler, arg2, t, state)

View Source

Specs

handle_event(handler(), Cizen.Event.t(), t(), state :: term()) ::
  resolve() | consume() | term()

Specs

init(handler(), t()) :: resolve() | alias_of() | term()