2

Please look at my answer below for the differences that I found and let me know if they are wrong or if there are more differences. Thank you.

domp
  • 751
  • 1
  • 11
  • 23

1 Answers1

2

The difference that I saw on Elixir's documentation

  • handle_call must return a reply and handle_event does not have to return a reply

It seems to me that event is used to change the state and call is used to get the state.

domp
  • 751
  • 1
  • 11
  • 23
  • 2
    `handle_event` can be synchronous by using `sync_notify`. The difference is that `handle_call` will call one particular event handler in the event manager, `handle_event` will be called in all of them for every event. – José Valim Sep 30 '15 at 06:04
  • 1
    So let's say I `notify` an event `{:custom_event, 1}`, every `handle_event` methods defined in the module will be called once? And if I make a `call`, only the `handle_call` for `{:custom_event, 1}` will be called? – domp Sep 30 '15 at 06:16
  • 1
    No. A GenEvent is made of an event manager and many event handlers. You implement the handler in a module and you can add many handlers to a manager. So nofity will be call `handle_event` in all installed event handlers. – José Valim Oct 02 '15 at 12:09