API Docs for: 1.0.0
Show:

SessionManager Class

Session manager contains core functions related to session state.

Constructor

Methods

_applyDiff

(
  • base
  • diff
)
private

Parameters:

  • base Object
  • diff Object

_cacheClassInfo

(
  • linkableObject
  • className
)
private

Parameters:

_getRegisteredChildren

(
  • parent
)
Array private

Parameters:

  • parent ILinkableChild

    A parent object to get the registered children of.

Returns:

Array:

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
)
Array

Parameters:

  • treeItem WeaveTreeItem

Returns:

Array:

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:

  • relevantContext Object
  • groupedCallback Function
  • triggerCallbackNow Boolean

combineDiff

(
  • baseDiff
  • diffToAdd
)
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 computeDiff

computeDiff

(
  • oldState
  • 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:

Object:

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:

disposeObject

(
  • object
)

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

Parameters:

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:

  • parent ILinkableChild

    A parent that the specified child objects were previously registered with.

  • child ILinkableChild

    The child object to remove from the session state of the parent.

getCallbackCollection

(
  • linkableObject
)
CallbackCollection

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:

  • linkableObject ILinkableObject

    An ILinkableObject to get the associated ICallbackCollection for.

Returns:

CallbackCollection:

The CallbackCollection associated with the given object.

getLinkableDescendants

(
  • root
  • filter
)
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

    An optional Class definition which will be used to filter the results.

Returns:

Array:

An Array containing a list of descendant objects. See getLinkableOwner

getLinkableOwner

(
  • child
)
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 owner. See getLinkableDescendants

getLinkablePropertyNames

(
  • linkableObject
  • filtered
)
Array

This function gets a list of sessioned property names so accessor functions for non-sessioned properties do not have to be called.

Parameters:

  • linkableObject ILinkableObject

    An object containing sessioned properties.

  • filtered Boolean

    If set to true, filters out deprecated, null, and excluded properties.

Returns:

Array:

An Array containing the names of the sessioned properties of that object class.

getSessionState

(
  • linkableObject
)
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 setSessionState

getSessionStateTree

(
  • root
  • objectName
  • objectTypeFilter
)
WeaveTreeItem

Parameters:

  • root ILinkableObject

    The linkable object to be placed at the root node of the tree.

  • objectName String
  • objectTypeFilter Object

Returns:

WeaveTreeItem:

A tree of nodes with the properties "label", "object", and "children"

objectWasDisposed

(
  • object
)
Boolean

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

Parameters:

  • object Object

    An object to check.

Returns:

Boolean:

A value of true if disposeObject() was called for the specified object. see disposeObject

registerDisposableChild

(
  • disposableParent
  • 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. The child will be disposed when the parent is disposed.

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:

Object:

The linkableChild object that was passed to the function.

Example:

usage: const foo = registerDisposableChild(this, someLinkableNumber);

registerLinkableChild

(
  • linkableParent
  • linkableChild
  • callback
  • useGroupedCallback
)
Object

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:

  • linkableParent Object

    A parent ILinkableObject that the child will be registered with.

  • linkableChild ILinkableObject

    The child ILinkableObject to register as a child.

  • callback Function

    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

    If this is true, addGroupedCallback() will be used instead of addImmediateCallback().

Returns:

Object:

The linkableChild object that was passed to the function.

Example:

usage: const foo = registerLinkableChild(this, someLinkableNumber, handleFooChange);

removeTreeCallback

(
  • groupedCallback
)

Parameters:

  • groupedCallback Function

setSessionState

(
  • linkableObject
  • newState
  • removeMissingDynamicObjects
)

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

    If 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:

  • parent ILinkableChild

    A parent that the specified child objects were previously registered with.

  • child ILinkableChild

    The 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"