Notification of Changes to Parts

By signaling events, a part can notify other parts that a state or value in its interface has changed. Events can be signaled when the state of a view part changes, such as when a push button is clicked or when a window is opened, as well as when the state of a model part changes, such as when the balance in a bank account becomes negative. Events can also be signaled when the value of a part's property changes, such as when money is deposited into or withdrawn from a bank account.

Notifications appear as messages broadcast to all parts that are observers of the event. Observers of an event are those parts that depend on the event's occurrence. The event interface is represented as follows:

  static INotificationId const anEventId;

anEventId is the notification ID for the event.

Several different options are available to signal events. The first option is an example of using the event interface for attribute notification with event parameters:

  notifyObservers(INotificationEvent(anEventId, *this, true,
(void*)aValue));

The following simpler call can be made if no event parameters are to be passed:

  notifyObservers(INotificationEvent(anEventId, *this));

Parts can also signal events when no attributes have changed, as follows:

  notifyObservers(INotificationEvent(anEventId, *this, false,
(void*)aValue));

The following simpler call can be made if no event parameters are to be passed:

  notifyObservers(INotificationEvent(anEventId, *this, false));


Related concepts
Access to a Part's Properties