Packageweavejs.core
Classpublic class LinkableVariable
InheritanceLinkableVariable Inheritance CallbackCollection Inheritance Object
Implements ILinkableVariable, ICallbackCollection, IDisposableObject
Subclasses ColorRamp, LinkableBoolean, LinkableNumber, LinkablePlaceholder, LinkableString

LinkableVariable allows callbacks to be added that will be called when the value changes. A LinkableVariable has an optional type restriction on the values it holds.



Public Properties
 PropertyDefined By
 InheritedcallbacksAreDelayed : Boolean
[read-only]
CallbackCollection
 Inherited_linkableObject : ILinkableObject
CallbackCollection
  locked : Boolean
[read-only] This is set to true when lock() is called.
LinkableVariable
  state : Object
LinkableVariable
 InheritedtriggerCounter : uint
[read-only]
CallbackCollection
 InheritedwasDisposed : Boolean
[read-only] This flag becomes true after dispose() is called.
CallbackCollection
Protected Properties
 PropertyDefined By
  _bypassDiff : Boolean = true
If true, session states will be altered to bypass the diff calculation on DynamicState Arrays.
LinkableVariable
  _locked : Boolean = false
This is set to true when lock() is called.
LinkableVariable
 Inherited_preCallback : Function = null
This is the function that gets called immediately before every callback.
CallbackCollection
  _primitiveType : Boolean = false
This is true if the _sessionStateType is a primitive type.
LinkableVariable
  _sessionStateExternal : * = undefined
Available externally via getSessionState()
LinkableVariable
  _sessionStateInternal : * = undefined
Cannot be modified externally because it is not returned by getSessionState()
LinkableVariable
  _sessionStateType : Class = null
Type restriction passed in to the constructor.
LinkableVariable
  _sessionStateWasSet : Boolean = false
This is true if the session state has been set at least once.
LinkableVariable
  _verifier : Function = null
This function is used to prevent the session state from having unwanted values.
LinkableVariable
Public Methods
 MethodDefined By
  
LinkableVariable(sessionStateType:Class = null, verifier:Function = null, defaultValue:*, defaultValueTriggersCallbacks:Boolean = true)
If a defaultValue is specified, callbacks will be triggered in a later frame unless they have already been triggered before then.
LinkableVariable
 Inherited
addDisposeCallback(relevantContext:Object, callback:Function, allowDelay:Boolean = false):void
CallbackCollection
 Inherited
addGroupedCallback(relevantContext:Object, groupedCallback:Function, triggerCallbackNow:Boolean = false, delayWhileBusy:Boolean = true):void
CallbackCollection
 Inherited
addImmediateCallback(relevantContext:Object, callback:Function, runCallbackNow:Boolean = false, alwaysCallLast:Boolean = false):void
CallbackCollection
 Inherited
CallbackCollection
  
This function may be called to detect change to a non-primitive session state in case it has been modified externally.
LinkableVariable
  
dispose():void
[override]
LinkableVariable
  
LinkableVariable
  
The type restriction passed in to the constructor.
LinkableVariable
  
lock():void
Call this function when you do not want to allow any more changes to the value of this sessioned property.
LinkableVariable
 Inherited
removeCallback(relevantContext:Object, callback:Function):void
CallbackCollection
 Inherited
CallbackCollection
  
setSessionState(value:Object):void
LinkableVariable
 Inherited
CallbackCollection
  
verifyValue(value:Object):Boolean
This function will verify if a given value is a valid session state for this linkable variable.
LinkableVariable
Protected Methods
 MethodDefined By
 Inherited
_runCallbacksImmediately(... preCallbackParams):void
This function runs callbacks immediately, ignoring any delays.
CallbackCollection
  
sessionStateEquals(otherSessionState:*):Boolean
This function is used in setSessionState() to determine if the value has changed or not.
LinkableVariable
Public Constants
 ConstantDefined By
 InheritedDEFAULT_TRIGGER_COUNT : uint = 1
[static] This is the default value of triggerCounter.
CallbackCollection
 InheritedSTACK_TRACE_TRIGGER : String = This is the stack trace from when the callbacks were last triggered.
[static]
CallbackCollection
Property Detail
_bypassDiffproperty
protected var _bypassDiff:Boolean = true

If true, session states will be altered to bypass the diff calculation on DynamicState Arrays.

_lockedproperty 
protected var _locked:Boolean = false

This is set to true when lock() is called.

_primitiveTypeproperty 
protected var _primitiveType:Boolean = false

This is true if the _sessionStateType is a primitive type.

_sessionStateExternalproperty 
protected var _sessionStateExternal:* = undefined

Available externally via getSessionState()

_sessionStateInternalproperty 
protected var _sessionStateInternal:* = undefined

Cannot be modified externally because it is not returned by getSessionState()

_sessionStateTypeproperty 
protected var _sessionStateType:Class = null

Type restriction passed in to the constructor.

_sessionStateWasSetproperty 
protected var _sessionStateWasSet:Boolean = false

This is true if the session state has been set at least once.

_verifierproperty 
protected var _verifier:Function = null

This function is used to prevent the session state from having unwanted values. Function signature should be function(value::Boolean

lockedproperty 
locked:Boolean  [read-only]

This is set to true when lock() is called. Subsequent calls to setSessionState() will have no effect.


Implementation
    public function get locked():Boolean
stateproperty 
state:Object


Implementation
    public function get state():Object
    public function set state(value:Object):void
Constructor Detail
LinkableVariable()Constructor
public function LinkableVariable(sessionStateType:Class = null, verifier:Function = null, defaultValue:*, defaultValueTriggersCallbacks:Boolean = true)

If a defaultValue is specified, callbacks will be triggered in a later frame unless they have already been triggered before then. This behavior is desirable because it allows the initial value to be handled by the same callbacks that handles new values.

Parameters
sessionStateType:Class (default = null) — The type of values accepted for this sessioned property.
 
verifier:Function (default = null) — A function that returns true or false to verify that a value is accepted as a session state or not. The function signature should be function(value::Boolean.
 
defaultValue:* (default = NaN) — The default value for the session state.
 
defaultValueTriggersCallbacks:Boolean (default = true) — Set this to false if you do not want the callbacks to be triggered one frame later after setting the default value.
Method Detail
detectChanges()method
public function detectChanges():void

This function may be called to detect change to a non-primitive session state in case it has been modified externally.

dispose()method 
override public function dispose():void

getSessionState()method 
public function getSessionState():Object

Returns
Object
getSessionStateType()method 
public function getSessionStateType():Class

The type restriction passed in to the constructor.

Returns
Class
lock()method 
public function lock():void

Call this function when you do not want to allow any more changes to the value of this sessioned property.

sessionStateEquals()method 
protected function sessionStateEquals(otherSessionState:*):Boolean

This function is used in setSessionState() to determine if the value has changed or not. Classes that extend this class may override this function.

Parameters

otherSessionState:*

Returns
Boolean
setSessionState()method 
public function setSessionState(value:Object):void

Parameters

value:Object

verifyValue()method 
public function verifyValue(value:Object):Boolean

This function will verify if a given value is a valid session state for this linkable variable.

Parameters

value:Object — The value to verify.

Returns
Boolean — A value of true if the value is accepted by this linkable variable.