The following diagram illustrates the event model.Listener1Properties
EventName = ‘InsufficientFunds’
FunctionHandle = @Callback1Listener2Properties
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
AccountBalanceMethodsEvents
InsufficientFundsInsufficientFundsInsufficientFundsif AccountBalance <= 0
notify(obj,’InsufficientFunds’);
end
deposit
withdrawLimitations
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