Notifications can be used for a loose coupling between
objects. Listener objects subscribe to an event of the caller object
by sending it a :send-on-event message. In
Example B.1 the clients of a Cook want to
receive a :go-for-lunch message when the Cook issues
the lunch-is-ready event. Therefore, they register an
appropriate notification at line 30 and 31.
After the cook finishes baking the lunch (in the :prepare-lunch method at line 10), he issues the lunch-is-ready event with the effect that Chris and Irmi receive their desired :go-for-lunch message. We see the corresponding screen outputs in Example B.2.
Notifications are particularly useful if objects are forced to communicate asynchronously with each other. This is typically the case for graphical user interfaces or processes of the operating system, where callbacks are involved.