Class Connectable

Summary


 A Connectable is an object that is capable of sending events to objects
 that want to be informed when something of interest happens. Generally it
 is an object to which other objects may connect for info. In the GUI classes
 for example, every component is a Connectable and those of them that
 actually receive input are probably connected to by some object.  The
 Connectable informs its subscribers of an event via its fire() method,
 which generally calls one of their methods as specified when they connected.

 In many Connectable architectures there is only one listener so a list of
 listeners is overkill. On the other hand, there are other connectable
 architectures where a central Connectable is managing large numbers of
 relationships. So Connectable is all about scalability. The code promotes
 on demand down the following list of representations (it does not demote).

 0  listeners: listeners is &null to begin with. Many connectables will
    have no listener.
 1  listener: listeners is the Subscription object. This is common in GUIs.
 2+ listeners, all the same type: listeners is a list
 2+ listeners, different types: listeners is a table of lists, keyed by type

Package:
util
File:
connectable.icn
Methods:
connect, disconnect, disconnect_all, disconnect_fromlist, fire, genlisteners

Fields:
listeners

Source code.

Details
Constructor

Connectable(listeners)

Methods:

connect(obj, meth, typ)


 Create and connect a Subscription to this object.
 @return the Subscription created and added.


disconnect(l)


 Remove a Subscription previously returned by {connect}


disconnect_all(obj)


 Remove all {Subscription}s with the given object field.


disconnect_fromlist(L, obj)


fire(typ, param)


 Helper method to create and fire an Event object from the given parameters.


genlisteners(typ)


Fields:
listeners


This page produced by UniDoc on 2021/04/15 @ 23:59:53.