From a5af68915bf3d1a6ae8b42e316c0b42471654e48 Mon Sep 17 00:00:00 2001 From: Corey Powell Date: Mon, 4 Apr 2022 00:02:21 -0500 Subject: [PATCH] Correctly handle init/1 {:ok, state, options} --- lib/freddy/core/actor.ex | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/freddy/core/actor.ex b/lib/freddy/core/actor.ex index 9c6b617..9a56ce2 100644 --- a/lib/freddy/core/actor.ex +++ b/lib/freddy/core/actor.ex @@ -167,16 +167,28 @@ defmodule Freddy.Core.Actor do @impl true def init({mod, config, initial}) do case mod.init(initial) do - {:ok, given} -> {:ok, state(mod: mod, config: config, given: given)} - ignore_or_stop -> ignore_or_stop + {:ok, given} -> + {:ok, state(mod: mod, config: config, given: given)} + + {:ok, given, options} -> + {:ok, state(mod: mod, config: config, given: given), options} + + :ignore -> + :ignore + + {:stop, _reason} = stop -> + stop end end @impl true def handle_disconnected(reason, state(mod: mod, given: given) = state) do case mod.handle_disconnected(reason, given) do - {:noreply, new_given} -> {:noreply, state(state, given: new_given)} - {:stop, reason, new_given} -> {:stop, reason, state(state, given: new_given)} + {:noreply, new_given} -> + {:noreply, state(state, given: new_given)} + + {:stop, reason, new_given} -> + {:stop, reason, state(state, given: new_given)} end end