-
Notifications
You must be signed in to change notification settings - Fork 14
Util_Listeners
The Listeners
package implements a simple observer/listener design pattern.
A subscriber registers to a list. When a change is made on an object, the
application can notify the subscribers which are then called with the object.
The listeners list contains a list of listener interfaces.
L : Util.Listeners.List;
The list is heterogeneous meaning that several kinds of listeners could be registered.
First the Observers
package must be instantiated with the type being
observed. In the example below, we will observe a string:
package String_Observers is new Util.Listeners.Observers (String);
Now we must implement the string observer:
type String_Observer is new String_Observer.Observer with null record;
procedure Update (List : in String_Observer; Item : in String);
An instance of the string observer must now be registered in the list.
O : aliased String_Observer;
L.Append (O'Access);
Notifying the listeners is done by invoking the Notify
operation
provided by the String_Observers
package:
String_Observer.Notify (L, "Hello");
Generated by Dynamo from util-listeners.ads