Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.35 KB | None | 0 0
  1. package;
  2.  
  3. class Event<T>
  4. {
  5.     private var _list:Array<T>;
  6.    
  7.     public function new()
  8.     {
  9.         _list = [];
  10.     }
  11.    
  12.     public function addListener(f:T) {
  13.         if (_list.indexOf(f) > -1) return;
  14.         _list.push(f);
  15.     }
  16.    
  17.     public function removeListener(f:T) {
  18.         _list.remove(f);
  19.     }
  20.    
  21.     public function dispatch(f:Array<T>->Void) {
  22.         if (f != null) f(_list);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement