Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created July 22, 2014 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josevalim/3e1817e2e9b5b282fdbf to your computer and use it in GitHub Desktop.
Save josevalim/3e1817e2e9b5b282fdbf to your computer and use it in GitHub Desktop.
iex(1)> defmodule Foo do
...(1)> use GenEvent
...(1)> end
{:module, Foo,
<<70, 79, 82, 49, 0, 0, 8, 144, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 2, 7, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 2, 104, 2, 100, 0, 4, ...>>,
[true, true, true, true, true, true]}
iex(2)> {:ok, pid} = GenEvent.start_link
{:ok, #PID<0.50.0>}
iex(3)> GenEvent.add_handler(pid, Foo, [])
:ok
iex(4)> GenEvent.call(pid, Foo, :ok)
=ERROR REPORT==== 22-Jul-2014::08:58:46 ===
** gen_event handler 'Elixir.Foo' crashed.
** Was installed in <0.50.0>
** Last event was: ok
** When handler state == []
** Reason == {bad_call,ok}
{:error, {:EXIT, {:bad_call, :ok}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment