Generic Event Handling
An event is just something that happens—something noteworthy that the programmer thinks somebody should do something about.
When we’re programming and something noteworthy happens, we just
send an event message to a registered process, like
this:
| | RegProcName ! {event, E} |
E is the event (any Erlang term). RegProcName
is the name of a registered process.
We don’t know (or care) what happens to the message after we have sent it. We have done our job and told somebody else that something has happened.
Now let’s turn our attention to the process that receives the
event messages. This is called an event handler. The simplest
possible event handler is a “do nothing” handler. When
it receives an {event, X} message, it does ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access