New to elixir and I'm following along with José Valim's post https://howistart.org/posts/elixir/1
I am having trouble having the Supervisor to start a child as i get the error:
iex(1)> Portal.shoot(:orange)
{:error, {:invalid_child_spec, [:orange]}}
Help would be greatly appreciated!
Here is the Portal module
defmodule Portal do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
worker(Portal.Door, [])
]
opts = [strategy: :simple_one_for_one, name: Portal.Supervisor]
Supervisor.start_link(children, opts)
end
@doc """
Shoots a new door with the given `color`
"""
def shoot(color) do
Supervisor.start_child(Portal.Supervisor, [color])
end
Here is the Portal.Door module and the start_link function that should be getting invoked
defmodule Portal.Door do
def start_link(color) do
Agent.start_link(fn -> [] end, name: color)
end
end
, and see if it works? I copied this and added the 2 missingend
and it worked for me yesterday. – Dogbert