Packagecom.threerings.util
Classpublic class ObserverList



Protected Properties
 PropertyDefined by
  _list : Array
The actual list of observers.
ObserverList
  _notifyPolicy : int
Our notification policy.
ObserverList
Public Methods
 MethodDefined by
  
ObserverList(notifyPolicy:int = 2)
Constructor
ObserverList
  
add(observer:Object, index:int = -1):void
Add an observer to this list.
ObserverList
  
apply(func:Function):void
Apply some operation to all observers.
ObserverList
  
remove(observer:Object):void
Remove an observer from this list.
ObserverList
  
size():int
Return the size of the list.
ObserverList
Public Constants
 ConstantDefined by
  FAST_UNSAFE_NOTIFY : int = 2
[static] A notification ordering policy wherein the observers are notified last to first so that they can be removed during the notification process and new observers added will not inadvertently be notified as well, but no copy of the observer list need be made.
ObserverList
  SAFE_IN_ORDER_NOTIFY : int = 1
[static] A notification ordering policy indicating that the observers should be notified in the order they were added and that the notification should be done on a snapshot of the array.
ObserverList
Property detail
_listproperty
protected var _list:Array

The actual list of observers.

_notifyPolicyproperty 
protected var _notifyPolicy:int

Our notification policy.

Constructor detail
ObserverList()constructor
public function ObserverList(notifyPolicy:int = 2)

Constructor

Parameters
notifyPolicy:int (default = 2)
Method detail
add()method
public function add(observer:Object, index:int = -1):void

Add an observer to this list.

Parameters
observer:Object — the index at which to add the observer, or -1 for the end.
 
index:int (default = -1)
apply()method 
public function apply(func:Function):void

Apply some operation to all observers. The function to be passed in should expect one argument and either return void or a Boolean. If returning a Boolean, returning false indicates that the observer should be removed from the list.

Parameters
func:Function
remove()method 
public function remove(observer:Object):void

Remove an observer from this list.

Parameters
observer:Object
size()method 
public function size():int

Return the size of the list.

Returns
int
Constant detail
FAST_UNSAFE_NOTIFYconstant
public static const FAST_UNSAFE_NOTIFY:int = 2

A notification ordering policy wherein the observers are notified last to first so that they can be removed during the notification process and new observers added will not inadvertently be notified as well, but no copy of the observer list need be made. This will not work if observers are added or removed from arbitrary positions in the list during a notification call.

SAFE_IN_ORDER_NOTIFYconstant 
public static const SAFE_IN_ORDER_NOTIFY:int = 1

A notification ordering policy indicating that the observers should be notified in the order they were added and that the notification should be done on a snapshot of the array.