The following diagram illustrates the event model.
Listener1
Properties
EventName = ‘InsufficientFunds’
FunctionHandle = @Callback1
Listener2
Properties
EventName = ‘InsufficientFunds’
FunctionHandle = @Callback2
- The notify method
triggers an event, and a
message is broadcast. - Listeners awaiting message
execute their callbacks.
(The broadcasting object
does not necessarily know
who is listening.)
- The withdraw method is called.
BankAccount
Properties
AccountNumber
AccountBalance
Methods
Events
InsufficientFunds
InsufficientFunds
InsufficientFunds
if AccountBalance <= 0
notify(obj,’InsufficientFunds’);
end
deposit
withdraw
Limitations
There are certain limitations to the use of events:
- The event source cannot guarantee that listeners exist when triggering the event.
- A listener cannot prevent other listeners from being notified that the event occurred.
Event and Listener Concepts