Notifiers and Observers

To register dependence upon a notifier, an observer calls the handleNotificationsFor function:

// *fiAccountNumEF is an IEntryField instance, a notifier
// The notification ID for the text attribute is inherited from ITextControl
 
handleNotificationsFor(IInterest(*fiAccountNumEF, ITextControl::textId));

To cancel registration, an observer calls the stopHandlingNotificationsFor function:

stopHandlingNotificationsFor(IInterest(*fiAccountNumEF, ITextControl::textId)); 

To signal an event, notifiers call the notifyObservers function. If event data is not passed with the notification, the call looks like this:

// Called from the setAccountNum function of OAContract
 
notifyObservers(INotificationEvent(IInterest(*this, OAContract::accountNumId)));

Otherwise, the call looks like this:

// Called from the enableIDvalid function of OAContractor
// The type of event data being passed is IString, represented by iContractorID
 
notifyObservers(INotificationEventFor<IString> (IInterest(*this, OAContractor::IdvalidId), iContractorID));

To ensure that all notifier objects can coexist, no data is stored in any notifier object. A notifier adds observers to an observer list and uses this list to notify observers in a first-in, first-notified manner.


Related concepts
About Implementing Notification