### Event Notification

You use the Notification classes to enable an object to be notified by other objects of any changes which it needs to know about. For example, in a compound document application which uses the model/view/presenter design, whenever the state of the data in a model changes, any views opened on the model that the change affects need to be informed so that the views can present the change to the user.

Your model should notify the view when the model's data is modified so that the view can redraw itself to reflect the change.

An object which issues notification to other objects of changes in its state is referred to as a notifier. The objects which receive such change notifications are referred to as observers. To become an observer, an object must register with the object whose state it wishes to observe. Once registered, when that object is modified, it issues notification to the registered observer objects, passing a notification event.

Any application object can use a notifier to notify observers of particular events or changes in its state.

In this example, the user interface can update the display whenever the model completes a recalculation requested by the user.

For other examples, a stock market ticker-tape component that constantly monitors stock reports needs to inform its associated view of changes to the incoming data, while a clock component needs to keep its display constantly updated.

### Notification Solutions

The notification classes implement three generic solutions:

- Synchronizing the states of two related objects.
- Filtering notifications in an application where one source can generate many events, such as might happen with a feature-rich user interface window.
- Using asynchronous notification to eliminate one event's blocking another, such as a print or save request preventing further data entry.

This version of IBM Open Class extends its previous notification services in two important ways:

- It offers asynchronous, in addition to synchronous, notification.
- It provides a filtering mechanism so that the client object can specify what types of notification to receive.

These enhancements lower the risk of application deadlocks, provide a more flexible programming model, and facilitate scalability. The Notification classes can be used with nonframework components (regular IBM Open Class applications) as well as with framework components (Component-based applications). They can be used for either synchronous or asynchronous notification, and for either single-threaded or multithreaded applications.