Class
caplin.core

ListenerFactory

Utility class for creating listener objects that re-route incoming events to a method of your choice.

This class is useful in the following scenarios:

  • Objects that are only interested in a single event, and don't want to implement the entire interface.
  • Objects that need to implement the same interface multiple times so they can observe multiple objects — this is only possible using proxy listeners like this.

Constructor Summary

Attributes Name and Description
caplin.core.ListenerFactory(Function fInterface, String sEvent)

Construct a new ListenerFactory that can create listeners for the given event, on the given interface.

Method Summary

Attributes Name and Description
Object createListener(Object oTarget, String sMethod)

Returns a listener that will forward received events through to the given method on the given object.

Constructor Detail

caplin.core.ListenerFactory(Function fInterface, String sEvent)

Construct a new ListenerFactory that can create listeners for the given event, on the given interface.

Parameters
Function fInterface The listener interface that objects created with this factory will implement.
String sEvent The particular event on the listener interface that will be proxied through.

Method Detail

Object createListener(Object oTarget, String sMethod)

Returns a listener that will forward received events through to the given method on the given object.

Parameters
Object oTarget The object that will be invoked when events are received.
String sMethod The name of the method to invoke on the target object.