Using the Components Framework Notification

1) Set up the notifier.

If your model is derived from IModel, it already has inherited notifier protocols. Simply provide a notification identifier for each type of change that might occur in your model:

//in myApp.hpp
static const INotificationId kModelChanged;
// in myApp.cpp
const INotificationId IMyModel::kModelChanged= 
                "IMyModel::kModelChanged";

Then, whenever the data in your model is changed, call your model's notifyOfChange function, passing the appropriate notification identifier.

2) Set up an observer.

In the simplest case, where the view is the observer, you can derive your application's view from IModelView. IModelView, a subclass of ISimpleView, provides and manages an observer for you. Simply override the handleModelChanged method you inherit from IModelView, to tell your view what action to take when it receives notification of a change in the model.

For instance, the following code simply refreshes the view:

void
IMyView::handleModelChanged(const INotificationEvent& event)
{
	refresh();
}