I have a simple event handler in elixir using GenEvent
:
defmodule myHandler do
use GenEvent
#Callback
def handle_event {:message, x}, state do
IO.puts("Message value is #{x}")
{:ok, [x|state]}
end
end
I can start one handler and a manager in the usual way:
{:ok, mgr} = GenEvent.start_link
myServer.start_link(mgr)
GenEvent.add_handler(mgr,myHandler, [])
However, I would like to start a supervision tree where there are N handlers, each with a different id, using the same manager.
I tried:
Gen.Event.add_handler({mgr, :id1},myHandler, [])
, with no luck! In stead I get the following error:
** (Mix) Could not start application : exited in: myApp.start(:normal, [])
** (EXIT) no connection to :id1
I'm a newbie to Elixir and so am struggling with the documentation a bit. I'd be grateful if someone can show me how! Thanks.