Packageweavejs.api.core
Interfacepublic interface ISessionManager
Implementors SessionManager

Session manager contains core functions for Weave related to session state.



Public Methods
 MethodDefined By
  
assignBusyTask(taskToken:Object, busyObject:ILinkableObject):void
This will assign an asynchronous task to a linkable object so that linkableObjectIsBusy(busyObject) will return true until all assigned tasks are unassigned using unassignBusyTask(taskToken).
ISessionManager
  
combineDiff(baseDiff:Object, diffToAdd:Object):Object
This modifies an existing diff to include an additional diff.
ISessionManager
  
computeDiff(oldState:Object, newState:Object):*
This function computes the diff of two session states.
ISessionManager
  
This function will copy the session state from one sessioned object to another.
ISessionManager
  
disposeObject(object:Object):void
This function should be called when an ILinkableObject or IDisposableObject is no longer needed.
ISessionManager
  
This function gets the ICallbackCollection associated with an ILinkableObject.
ISessionManager
  
getLinkableDescendants(root:ILinkableObject, filter:Class = null):Array
This function will return all the descendant objects that implement ILinkableObject.
ISessionManager
  
This function gets the ILinkableObject associated with an ICallbackCollection.
ISessionManager
  
This function gets the owner of a linkable object.
ISessionManager
  
This function returns a pointer to an ILinkableObject appearing in the session state.
ISessionManager
  
getOwner(child:Object):Object
This function gets the owner of an object.
ISessionManager
  
getPath(root:ILinkableObject, descendant:ILinkableObject):Array
Gets the path of names in the session state tree of the root object.
ISessionManager
  
getSessionState(linkableObject:ILinkableObject):Object
Gets the session state of an ILinkableObject.
ISessionManager
  
linkableObjectIsBusy(linkableObject:ILinkableObject):Boolean
This checks if any asynchronous tasks have been assigned to a linkable object or any of its registered descendants.
ISessionManager
  
This will link the session state of two ILinkableObjects.
ISessionManager
  
newDisposableChild(disposableParent:Object, disposableChildType:Class):*
This function will create a new instance of the specified child class and register it as a child of the parent.
ISessionManager
  
newLinkableChild(linkableParent:Object, linkableChildType:Class, callback:Function = null, useGroupedCallback:Boolean = false):*
This function will create a new instance of the specified child class and register it as a child of the parent.
ISessionManager
  
objectWasDisposed(object:Object):Boolean
This function checks if an object has been disposed by the ISessionManager.
ISessionManager
  
registerDisposableChild(disposableParent:Object, disposableChild:Object):*
This will register a child of a parent and cause the child to be disposed when the parent is disposed.
ISessionManager
  
registerLinkableChild(linkableParent:Object, linkableChild:ILinkableObject, callback:Function = null, useGroupedCallback:Boolean = false):*
This function tells the SessionManager that the session state of the specified child should appear in the session state of the specified parent, and the child should be disposed when the parent is disposed.
ISessionManager
  
setSessionState(linkableObject:ILinkableObject, newState:Object, removeMissingDynamicObjects:Boolean = true):void
Sets the session state of an ILinkableObject.
ISessionManager
  
unassignBusyTask(taskToken:Object):void
This will unassign an asynchronous task from all linkable objects it has been previously assigned to.
ISessionManager
  
This will unlink the session state of two ILinkableObjects that were previously linked with linkSessionState().
ISessionManager
Method Detail
assignBusyTask()method
public function assignBusyTask(taskToken:Object, busyObject:ILinkableObject):void

This will assign an asynchronous task to a linkable object so that linkableObjectIsBusy(busyObject) will return true until all assigned tasks are unassigned using unassignBusyTask(taskToken).

Parameters

taskToken:Object — A token representing an asynchronous task. If this is an AsyncToken, a responder will be added that will automatically call unassignBusyTask(taskToken) on success or failure.
 
busyObject:ILinkableObject — The object that is busy waiting for the task to complete.

See also

weave.api.core.IProgressIndicator.addTask()
unassignBusyTask()
linkableObjectIsBusy()
combineDiff()method 
public function combineDiff(baseDiff:Object, diffToAdd:Object):Object

This modifies an existing diff to include an additional diff.

Parameters

baseDiff:Object — The base diff which will be modified to include an additional diff.
 
diffToAdd:Object — The diff to add to the base diff. This diff will not be modified.

Returns
Object — The modified baseDiff, or a new diff object if baseDiff is a primitive value.

See also

computeDiff()method 
public function computeDiff(oldState:Object, newState:Object):*

This function computes the diff of two session states.

Parameters

oldState:Object — The source session state.
 
newState:Object — The destination session state.

Returns
* — A patch that generates the destination session state when applied to the source session state, or undefined if the two states are equivalent.

See also

copySessionState()method 
public function copySessionState(source:ILinkableObject, destination:ILinkableObject):void

This function will copy the session state from one sessioned object to another. If the two objects are of different types, the behavior of this function is undefined.

Parameters

source:ILinkableObject — A sessioned object to copy the session state from.
 
destination:ILinkableObject — A sessioned object to copy the session state to.

See also

disposeObject()method 
public function disposeObject(object:Object):void

This function should be called when an ILinkableObject or IDisposableObject is no longer needed.

Parameters

object:Object — An ILinkableObject or an IDisposableObject to clean up.

See also

getCallbackCollection()method 
public function getCallbackCollection(linkableObject:ILinkableObject):ICallbackCollection

This function gets the ICallbackCollection associated with an ILinkableObject. If there is no ICallbackCollection defined for the object, one will be created. This ICallbackCollection is used for reporting changes in the session state

Parameters

linkableObject:ILinkableObject — An ILinkableObject to get the associated ICallbackCollection for.

Returns
ICallbackCollection — The ICallbackCollection associated with the given object.
getLinkableDescendants()method 
public function getLinkableDescendants(root:ILinkableObject, filter:Class = null):Array

This function will return all the descendant objects that implement ILinkableObject. If the filter parameter is specified, the results will contain only those objects that extend or implement the filter class.

Parameters

root:ILinkableObject — A root object to get the descendants of.
 
filter:Class (default = null) — An optional Class definition which will be used to filter the results.

Returns
Array — An Array containing a list of descendant objects.

See also

getLinkableObjectFromCallbackCollection()method 
public function getLinkableObjectFromCallbackCollection(callbackCollection:ICallbackCollection):ILinkableObject

This function gets the ILinkableObject associated with an ICallbackCollection.

Parameters

callbackCollection:ICallbackCollection

Returns
ILinkableObject
getLinkableOwner()method 
public function getLinkableOwner(child:ILinkableObject):ILinkableObject

This function gets the owner of a linkable object. The owner of an object is defined as its first registered parent.

Parameters

child:ILinkableObject — An ILinkableObject that was registered as a child of another ILinkableObject.

Returns
ILinkableObject — The owner of the child object (the first parent that was registered with the child), or null if the child has no linkable owner.

See also

getObject()method 
public function getObject(root:ILinkableObject, path:Array):ILinkableObject

This function returns a pointer to an ILinkableObject appearing in the session state.

Parameters

root:ILinkableObject — The root object used to find a descendant object.
 
path:Array — A sequence of child names used to refer to an object appearing in the session state. A child index number may be used in place of a name in the path when its parent object is a LinkableHashMap.

Returns
ILinkableObject — A pointer to the object referred to by objectPath.

See also

getOwner()method 
public function getOwner(child:Object):Object

This function gets the owner of an object. The owner of an object is defined as its first registered parent.

Parameters

child:Object — An Object that was registered as a child of another Object.

Returns
Object — The owner of the child object (the first parent that was registered with the child), or null if the child has no owner.
getPath()method 
public function getPath(root:ILinkableObject, descendant:ILinkableObject):Array

Gets the path of names in the session state tree of the root object.

Parameters

root:ILinkableObject — The root object used to generate a session state tree.
 
descendant:ILinkableObject — The descendant object to find in the session state tree.

Returns
Array — The path from root to descendant, or null if the descendant does not appear in the session state.

See also

getSessionState()method 
public function getSessionState(linkableObject:ILinkableObject):Object

Gets the session state of an ILinkableObject.

Parameters

linkableObject:ILinkableObject — An object containing sessioned properties (sessioned objects may be nested).

Returns
Object — An object containing the values from the sessioned properties.

See also

linkableObjectIsBusy()method 
public function linkableObjectIsBusy(linkableObject:ILinkableObject):Boolean

This checks if any asynchronous tasks have been assigned to a linkable object or any of its registered descendants.

Parameters

linkableObject:ILinkableObject — The object to check.

Returns
Boolean — A value of true if any asynchronous tasks have been assigned to the object.

See also

linkSessionState()method 
public function linkSessionState(primary:ILinkableObject, secondary:ILinkableObject):void

This will link the session state of two ILinkableObjects. The session state of 'primary' will be copied over to 'secondary' after linking them.

Parameters

primary:ILinkableObject — An ILinkableObject to give authority over the initial shared value.
 
secondary:ILinkableObject — The ILinkableObject to link with 'primary' via session state.

See also

newDisposableChild()method 
public function newDisposableChild(disposableParent:Object, disposableChildType:Class):*

This function will create a new instance of the specified child class and register it as a child of the parent. The child will be disposed when the parent is disposed. Use this function when a child object can be disposed but you do not want to link the callbacks or either object is not an ILinkableObject. Example usage: public const foo:LinkableNumber = newDisposableChild(this, LinkableNumber);

Parameters

disposableParent:Object — A parent ILinkableObject to create a new child for.
 
disposableChildType:Class — The class definition that implements ILinkableObject used to create the new child.

Returns
* — The new child object.

See also

newLinkableChild()method 
public function newLinkableChild(linkableParent:Object, linkableChildType:Class, callback:Function = null, useGroupedCallback:Boolean = false):*

This function will create a new instance of the specified child class and register it as a child of the parent. If a callback function is given, the callback will be added to the child and cleaned up when the parent is disposed. Example usage: public const foo:LinkableNumber = newLinkableChild(this, LinkableNumber, handleFooChange);

Parameters

linkableParent:Object — A parent ILinkableObject to create a new child for.
 
linkableChildType:Class — The class definition that implements ILinkableObject used to create the new child.
 
callback:Function (default = null) — A callback with no parameters that will be added to the child that will run before the parent callbacks are triggered, or during the next ENTER_FRAME event if a grouped callback is used.
 
useGroupedCallback:Boolean (default = false) — If this is true, addGroupedCallback() will be used instead of addImmediateCallback().

Returns
* — The new child object.

See also

objectWasDisposed()method 
public function objectWasDisposed(object:Object):Boolean

This function checks if an object has been disposed by the ISessionManager.

Parameters

object:Object — An object to check.

Returns
Boolean — A value of true if disposeObject() was called for the specified object.

See also

registerDisposableChild()method 
public function registerDisposableChild(disposableParent:Object, disposableChild:Object):*

This will register a child of a parent and cause the child to be disposed when the parent is disposed. Use this function when a child object can be disposed but you do not want to link the callbacks or either object is not an ILinkableObject. Example usage: public const foo:LinkableNumber = registerDisposableChild(this, someLinkableNumber);

Parameters

disposableParent:Object — A parent disposable object that the child will be registered with.
 
disposableChild:Object — The disposable object to register as a child of the parent.

Returns
* — The linkableChild object that was passed to the function.

See also

registerLinkableChild()method 
public function registerLinkableChild(linkableParent:Object, linkableChild:ILinkableObject, callback:Function = null, useGroupedCallback:Boolean = false):*

This function tells the SessionManager that the session state of the specified child should appear in the session state of the specified parent, and the child should be disposed when the parent is disposed. There is one other requirement for the child session state to appear in the parent session state -- the child must be accessible through a public variable of the parent or through an accessor function of the parent. This function will add callbacks to the sessioned children that cause the parent callbacks to run. If a callback function is given, the callback will be added to the child and cleaned up when the parent is disposed. Example usage: public const foo:LinkableNumber = registerLinkableChild(this, someLinkableNumber, handleFooChange);

Parameters

linkableParent:Object — A parent ILinkableObject that the child will be registered with.
 
linkableChild:ILinkableObject — The child ILinkableObject to register as a child.
 
callback:Function (default = null) — A callback with no parameters that will be added to the child that will run before the parent callbacks are triggered, or during the next ENTER_FRAME event if a grouped callback is used.
 
useGroupedCallback:Boolean (default = false) — If this is true, addGroupedCallback() will be used instead of addImmediateCallback().

Returns
* — The linkableChild object that was passed to the function.

See also

setSessionState()method 
public function setSessionState(linkableObject:ILinkableObject, newState:Object, removeMissingDynamicObjects:Boolean = true):void

Sets the session state of an ILinkableObject.

Parameters

linkableObject:ILinkableObject — An object containing sessioned properties (sessioned objects may be nested).
 
newState:Object — An object containing the new values for sessioned properties in the sessioned object.
 
removeMissingDynamicObjects:Boolean (default = true) — If true, this will remove any properties from an ILinkableCompositeObject that do not appear in the session state.

See also

unassignBusyTask()method 
public function unassignBusyTask(taskToken:Object):void

This will unassign an asynchronous task from all linkable objects it has been previously assigned to. If the task was previously registered with WeaveAPI.ProgressManager, this will call WeaveAPI.ProgressManager.removeTask().

Parameters

taskToken:Object — A token representing an asynchronous task.

See also

weave.api.core.IProgressIndicator.removeTask()
assignBusyTask()
linkableObjectIsBusy()
unlinkSessionState()method 
public function unlinkSessionState(first:ILinkableObject, second:ILinkableObject):void

This will unlink the session state of two ILinkableObjects that were previously linked with linkSessionState().

Parameters

first:ILinkableObject — The ILinkableObject to unlink from 'second'
 
second:ILinkableObject — The ILinkableObject to unlink from 'first'

See also