SessionManager Class
Session manager contains core functions related to session state.
Constructor
SessionManager
()
Item Index
Methods
- _applyDiff
- _cacheClassInfo
- _getRegisteredChildren
- _getTreeItemChildren
- addTreeCallback
- combineDiff
- computeDiff
- copySessionState
- disposeObject
- excludeLinkableChildFromSessionState
- getCallbackCollection
- getLinkableDescendants
- getLinkableOwner
- getLinkablePropertyNames
- getSessionState
- getSessionStateTree
- objectWasDisposed
- registerDisposableChild
- registerLinkableChild
- removeTreeCallback
- setSessionState
- unregisterLinkableChild
Properties
- _aBusyTraversal
- _childToOwnerMap
- _childToParentMap
- _classNameToSessionedPropertyNames
- _d2dOwnerTask
- _d2dTaskOwner
- _dBusyTraversal
- _disposedObjectsMap
- _dTaskStackTrace
- _dUnbusyStackTraces
- _dUnbusyTriggerCounts
- _getSessionStateIgnoreList
- _ownerToChildMap
- _parentToChildMap
- _treeCache
- _treeCallbacks
- DIFF_DELETE static
Methods
_applyDiff
-
base -
diff
Parameters:
-
baseObject -
diffObject
_cacheClassInfo
-
linkableObject -
className
Parameters:
-
linkableObjectILinkableObject -
classNameString
_getRegisteredChildren
-
parent
Parameters:
-
parentILinkableChildA parent object to get the registered children of.
Returns:
An Array containing a list of linkable objects that have been registered as children of the specified parent. This list includes all children that have been registered, even those that do not appear in the session state.
_getTreeItemChildren
-
treeItem
Parameters:
-
treeItemWeaveTreeItem
Returns:
addTreeCallback
-
relevantContext -
groupedCallback -
triggerCallbackNow
Adds a grouped callback that will be triggered when the session state tree changes. USE WITH CARE. The groupedCallback should not run computationally-expensive code.
Parameters:
-
relevantContextObject -
groupedCallbackFunction -
triggerCallbackNowBoolean
combineDiff
-
baseDiff -
diffToAdd
This modifies an existing diff to include an additional diff.
Parameters:
-
baseDiffObjectThe base diff which will be modified to include an additional diff.
-
diffToAddObjectThe diff to add to the base diff. This diff will not be modified.
Returns:
The modified baseDiff, or a new diff object if baseDiff is a primitive value. see computeDiff
computeDiff
-
oldState -
newState
This function computes the diff of two session states.
Parameters:
-
oldStateObjectThe source session state.
-
newStateObjectThe 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 combineDiff
copySessionState
-
source -
destination
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:
-
sourceILinkableObjectA sessioned object to copy the session state from.
-
destinationILinkableObjectA sessioned object to copy the session state to. see getSessionState see setSessionState
disposeObject
-
object
This function should be called when an ILinkableObject is no longer needed.
Parameters:
-
objectObjectAn ILinkableObject to clean up. see objectWasDisposed
excludeLinkableChildFromSessionState
-
parent -
child
This function will add or remove child objects from the session state of a parent. Use this function with care because the child will no longer be "sessioned." The child objects will continue to trigger the callbacks of the parent object, but they will no longer be considered a part of the parent's session state. If you are not careful, this will break certain functionalities that depend on the session state of the parent.
Parameters:
-
parentILinkableChildA parent that the specified child objects were previously registered with.
-
childILinkableChildThe child object to remove from the session state of the parent.
getCallbackCollection
-
linkableObject
This function gets the CallbackCollection associated with an ILinkableObject. If there is no CallbackCollection defined for the object, one will be created. This CallbackCollection is used for reporting changes in the session state
Parameters:
-
linkableObjectILinkableObjectAn ILinkableObject to get the associated ICallbackCollection for.
Returns:
The CallbackCollection associated with the given object.
getLinkableDescendants
-
root -
filter
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:
-
rootILinkableObjectA root object to get the descendants of.
-
filterClassAn optional Class definition which will be used to filter the results.
Returns:
An Array containing a list of descendant objects. See getLinkableOwner
getLinkableOwner
-
child
This function gets the owner of a linkable object. The owner of an object is defined as its first registered parent.
Parameters:
-
childILinkableObjectAn ILinkableObject that was registered as a child of another ILinkableObject.
Returns:
The owner of the child object (the first parent that was registered with the child), or null if the child has no owner. See getLinkableDescendants
getLinkablePropertyNames
-
linkableObject -
filtered
This function gets a list of sessioned property names so accessor functions for non-sessioned properties do not have to be called.
Parameters:
-
linkableObjectILinkableObjectAn object containing sessioned properties.
-
filteredBooleanIf set to true, filters out deprecated, null, and excluded properties.
Returns:
An Array containing the names of the sessioned properties of that object class.
getSessionState
-
linkableObject
Gets the session state of an ILinkableObject.
Parameters:
-
linkableObjectIlinkableObjectAn object containing sessioned properties (sessioned objects may be nested).
Returns:
An object containing the values from the sessioned properties. see setSessionState
getSessionStateTree
-
root -
objectName -
objectTypeFilter
Parameters:
-
rootILinkableObjectThe linkable object to be placed at the root node of the tree.
-
objectNameString -
objectTypeFilterObject
Returns:
A tree of nodes with the properties "label", "object", and "children"
objectWasDisposed
-
object
This function checks if an object has been disposed by the SessionManager.
Parameters:
-
objectObjectAn object to check.
Returns:
A value of true if disposeObject() was called for the specified object. see disposeObject
registerDisposableChild
-
disposableParent -
disposableChild
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. The child will be disposed when the parent is disposed.
Parameters:
-
disposableParentObjectA parent disposable object that the child will be registered with.
-
disposableChildObjectThe disposable object to register as a child of the parent.
Returns:
The linkableChild object that was passed to the function.
Example:
usage: const foo = registerDisposableChild(this, someLinkableNumber);
registerLinkableChild
-
linkableParent -
linkableChild -
callback -
useGroupedCallback
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.
Parameters:
-
linkableParentObjectA parent ILinkableObject that the child will be registered with.
-
linkableChildILinkableObjectThe child ILinkableObject to register as a child.
-
callbackFunctionA 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.
-
useGroupedCallbackBooleanIf this is true, addGroupedCallback() will be used instead of addImmediateCallback().
Returns:
The linkableChild object that was passed to the function.
Example:
usage: const foo = registerLinkableChild(this, someLinkableNumber, handleFooChange);
removeTreeCallback
-
groupedCallback
Parameters:
-
groupedCallbackFunction
setSessionState
-
linkableObject -
newState -
removeMissingDynamicObjects
Sets the session state of an ILinkableObject.
Parameters:
-
linkableObjectILinkableObjectAn object containing sessioned properties (sessioned objects may be nested).
-
newStateObjectAn object containing the new values for sessioned properties in the sessioned object.
-
removeMissingDynamicObjectsBooleanIf true, this will remove any properties from an ILinkableCompositeObject that do not appear in the session state. see getSessionState
unregisterLinkableChild
-
parent -
child
Use this function with care. This will remove child objects from the session state of a parent and stop the child from triggering the parent callbacks.
Parameters:
-
parentILinkableChildA parent that the specified child objects were previously registered with.
-
childILinkableChildThe child object to unregister from the parent.
Properties
_aBusyTraversal
Array
private
_childToOwnerMap
Map
private
This maps a child ILinkableObject to its registered owner.
_childToParentMap
Map
This maps a child ILinkableObject to a Dictionary, which maps each of its registered parent ILinkableObjects to a value of true if the child should appear in the session state automatically or false if not.
private
_classNameToSessionedPropertyNames
Object
private
_d2dOwnerTask
weavecore.Dictionary2D
private
_d2dTaskOwner
weavecore.Dictionary2D
private
_dBusyTraversal
Map
private
ILinkableObject -> Boolean
_disposedObjectsMap
Map
private
_dTaskStackTrace
Map
private
_dUnbusyStackTraces
Map
private
ILinkableObject -> String
_dUnbusyTriggerCounts
Map
private
ILinkableObject -> int
_getSessionStateIgnoreList
Map
private
keeps track of which objects are currently being traversed
_ownerToChildMap
Map
This maps a parent ILinkableObject to a Dictionary, which maps each child ILinkableObject it owns to a value of true.
private
_parentToChildMap
Map
This maps a parent ILinkableObject to a Dictionary, which maps each of its registered child ILinkableObjects to a value of true if the child should appear in the session state automatically or false if not.
private
_treeCache
weavecore.Dictionary2D
private
DIFF_DELETE
String
public
static
Default: "delete"
