Packageweavejs.api.core
Interfacepublic interface ICallbackCollection extends ILinkableObject
Implementors CallbackCollection, LinkableDynamicObject, LinkableVariable

This is an interface for adding and removing callback functions, and triggering them.



Public Properties
 PropertyDefined By
  callbacksAreDelayed : Boolean
[read-only] While this is true, it means the delay count is greater than zero and the effects of triggerCallbacks() are delayed until resumeCallbacks() is called to reduce the delay count.
ICallbackCollection
  triggerCounter : uint
[read-only] This counter gets incremented at the time that callbacks are triggered, before they are actually called.
ICallbackCollection
Public Methods
 MethodDefined By
  
addDisposeCallback(relevantContext:Object, callback:Function, allowDelay:Boolean = false):void
This will add a callback that will only be called once, when this callback collection is disposed.
ICallbackCollection
  
addGroupedCallback(relevantContext:Object, groupedCallback:Function, triggerCallbackNow:Boolean = false, delayWhileBusy:Boolean = true):void
Adds a callback that will only be called during a scheduled time each frame.
ICallbackCollection
  
addImmediateCallback(relevantContext:Object, callback:Function, runCallbackNow:Boolean = false, alwaysCallLast:Boolean = false):void
This adds the given function as a callback.
ICallbackCollection
  
This will delay the effects of triggerCallbacks() until a matching call is made to resumeCallbacks().
ICallbackCollection
  
removeCallback(relevantContext:Object, callback:Function):void
This function will remove a callback that was previously added.
ICallbackCollection
  
This should be called after delayCallbacks() to resume the callbacks.
ICallbackCollection
  
This will increase the triggerCounter, run immediate callbacks, and trigger grouped callbacks to be called later.
ICallbackCollection
Property Detail
callbacksAreDelayedproperty
callbacksAreDelayed:Boolean  [read-only]

While this is true, it means the delay count is greater than zero and the effects of triggerCallbacks() are delayed until resumeCallbacks() is called to reduce the delay count.


Implementation
    public function get callbacksAreDelayed():Boolean

See also

triggerCounterproperty 
triggerCounter:uint  [read-only]

This counter gets incremented at the time that callbacks are triggered, before they are actually called. It is necessary in some situations to check this counter to determine if cached data should be used.


Implementation
    public function get triggerCounter():uint

See also

Method Detail
addDisposeCallback()method
public function addDisposeCallback(relevantContext:Object, callback:Function, allowDelay:Boolean = false):void

This will add a callback that will only be called once, when this callback collection is disposed.

Parameters

relevantContext:Object — If this is not null, then the callback will be removed when the relevantContext object is disposed via SessionManager.dispose(). This parameter is typically a 'this' pointer.
 
callback:Function — The function to call when this callback collection is disposed.
 
allowDelay:Boolean (default = false) — If this is set to true, this callback will be delayed while callbacksAreDelayed is true.

addGroupedCallback()method 
public function addGroupedCallback(relevantContext:Object, groupedCallback:Function, triggerCallbackNow:Boolean = false, delayWhileBusy:Boolean = true):void

Adds a callback that will only be called during a scheduled time each frame. Grouped callbacks use a central trigger list, meaning that if multiple ICallbackCollections trigger the same grouped callback before the scheduled time, it will behave as if it were only triggered once. For this reason, grouped callback functions cannot have any parameters. Adding a grouped callback to a ICallbackCollection will undo any previous effects of addImmediateCallback() or addDisposeCallback() made to the same ICallbackCollection. The callback function will not be called recursively as a result of it triggering callbacks recursively.

Parameters

relevantContext:Object — The 'this' argument for the callback. The callback will be removed when the relevantContext object is disposed via Weave.dispose().
 
groupedCallback:Function — The callback function that will only be allowed to run during a scheduled time each frame. It must not require any parameters.
 
triggerCallbackNow:Boolean (default = false) — If this is set to true, the callback will be triggered to run during the scheduled time after it is added.
 
delayWhileBusy:Boolean (default = true) — Specifies whether to delay the callback while the object is busy. Once a given relevantContext/groupedCallback pair has been added with delayWhileBusy enabled, it will remain enabled even if the delayWhileBusy parameter is set to false in subsequent calls to addGroupedCallback() with the same relevantContext/groupedCallback parameters.

addImmediateCallback()method 
public function addImmediateCallback(relevantContext:Object, callback:Function, runCallbackNow:Boolean = false, alwaysCallLast:Boolean = false):void

This adds the given function as a callback. The function must not require any parameters. The callback function will not be called recursively as a result of it triggering callbacks recursively.

Parameters

relevantContext:Object — The 'this' argument for the callback. The callback will be removed when the relevantContext object is disposed via Weave.dispose().
 
callback:Function — The function to call when callbacks are triggered.
 
runCallbackNow:Boolean (default = false) — If this is set to true, the callback will be run immediately after it is added.
 
alwaysCallLast:Boolean (default = false) — If this is set to true, the callback will be always be called after any callbacks that were added with alwaysCallLast=false. Use this to establish the desired child-to-parent triggering order.

delayCallbacks()method 
public function delayCallbacks():void

This will delay the effects of triggerCallbacks() until a matching call is made to resumeCallbacks(). Pairs of calls to delayCallbacks() and resumeCallbacks() can be nested.

See also

removeCallback()method 
public function removeCallback(relevantContext:Object, callback:Function):void

This function will remove a callback that was previously added.

Parameters

relevantContext:Object — The relevantContext parameter that was given when the callback was added.
 
callback:Function — The function to remove from the list of callbacks.

resumeCallbacks()method 
public function resumeCallbacks():void

This should be called after delayCallbacks() to resume the callbacks. If delayCallbacks() is called multiple times, resumeCallbacks() must be called the same number of times in order to resume the callbacks.

See also

triggerCallbacks()method 
public function triggerCallbacks():void

This will increase the triggerCounter, run immediate callbacks, and trigger grouped callbacks to be called later. If delayCallbacks() was called, the callbacks will not be called immediately.

See also