Allow the event handler to be specified in the constructor.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5783 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2009-05-13 00:27:02 +00:00
parent 497ade64e8
commit 42f7ce23ac
+6 -1
View File
@@ -31,12 +31,17 @@ public class ExpiringSet extends EventDispatcher
* Initializes the expiring set.
*
* @param ttl Time to live value for set elements, in seconds.
* @param expireHandler a function to be conveniently registered as an event listener.
*/
public function ExpiringSet (ttl :Number)
public function ExpiringSet (ttl :Number, expireHandler :Function = null)
{
_ttl = Math.round(ttl * 1000);
_timer = new Timer(_ttl, 1);
_timer.addEventListener(TimerEvent.TIMER, checkTimer);
if (expireHandler != null) {
addEventListener(ELEMENT_EXPIRED, expireHandler);
}
}
/**