Javascript SharedObjects
(Created page with "== General == == Constructor == * '''new Engine.SharedObjects''' Create an object implementing the interface to shared objects. == Methods == * '''get(name)''' Retrieve a...") |
|||
(7 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
== General == | == General == | ||
+ | |||
+ | SharedObjects object implements an interface to a common list holding objects shared between scripts.<br/> | ||
+ | |||
+ | When set the module keeps a copy of the value.<br/> | ||
+ | Where retrieved the module returns a copy of the value.<br/> | ||
+ | |||
+ | See [[Javascript Object|Object]].assignProps() function. | ||
+ | |||
== Constructor == | == Constructor == | ||
Line 14: | Line 22: | ||
'''name''' Object name.<br/> | '''name''' Object name.<br/> | ||
Return:<br/> | Return:<br/> | ||
− | Object or null if not found. | + | Object (deep copy of existing) or null if not found. |
Line 21: | Line 29: | ||
Set or create a shared object.<br/> | Set or create a shared object.<br/> | ||
''create'' does not replace an existing object.<br> | ''create'' does not replace an existing object.<br> | ||
− | The shared objects list will always keep a copy of the given object.<br/> | + | The shared objects list will always keep a deep copy of the given object.<br/> |
Parameters:<br/> | Parameters:<br/> | ||
'''name''' Object name.<br/> | '''name''' Object name.<br/> | ||
Line 60: | Line 68: | ||
'''owned''' Boolean. True if calling script is owning the variable, false otherwise.<br/> | '''owned''' Boolean. True if calling script is owning the variable, false otherwise.<br/> | ||
'''persistent''' Boolean. True if variable is persistent (will not be deleted if script creating it is unloaded), false otherwise.<br/> | '''persistent''' Boolean. True if variable is persistent (will not be deleted if script creating it is unloaded), false otherwise.<br/> | ||
+ | |||
+ | |||
+ | |||
+ | [[Category:Javascript]] |
Latest revision as of 12:41, 9 September 2024
[edit] General
SharedObjects object implements an interface to a common list holding objects shared between scripts.
When set the module keeps a copy of the value.
Where retrieved the module returns a copy of the value.
See Object.assignProps() function.
[edit] Constructor
- new Engine.SharedObjects
Create an object implementing the interface to shared objects.
[edit] Methods
- get(name)
Retrieve a copy of a shared object.
Parameters:
name Object name.
Return:
Object (deep copy of existing) or null if not found.
- set(name,obj[,persistent[,assignPropsFlags]])
- create(name,obj[,persistent[,assignPropsFlags]])
Set or create a shared object.
create does not replace an existing object.
The shared objects list will always keep a deep copy of the given object.
Parameters:
name Object name.
obj Object value. Must be a non null object.
persistent Boolean. True if object is persistent (will not be deleted when script is unloaded). False to delete object when script is unloaded. Default: false.
assignPropsFlags Integer. Flags to be passed to Object.assignProps() function. Object.AssignDeepCopy and Object.AssignFreezeCopy will be forced by javascript.
Return:
Numeric number of copied properties. Negative if not set/created.
- clear(name)
Parameters:
name Object name.
- clearAll([owned])
Clear all shared objects.
Parameters:
owned Boolean. True to clear owned objects only. False to clear all shared objects.
- exists(name)
Parameters:
name Object name.
Return:
True if object exists, false otherwise.
- description(name)
Retrieve the description of a shared object.
Parameters:
name Object name.
Return:
Object with variable description, null if not found.
Description:
name Object name.
owned Boolean. True if calling script is owning the variable, false otherwise.
persistent Boolean. True if variable is persistent (will not be deleted if script creating it is unloaded), false otherwise.