State Class
The State class maintains state for a collection of named items, with a varying number of properties defined.
It avoids the need to create a separate class for the item, and separate instances of these classes for each item, by storing the state in a 2 level hash table, improving performance when the number of items is likely to be large.
Constructor
State
()
Methods
add
-
name
-
key
-
val
Adds a property to an item.
addAll
-
name
-
obj
Adds multiple properties to an item.
get
-
name
-
key
For a given item, returns the value of the property requested, or undefined if not found.
Returns:
getAll
-
name
-
reference
For the given item, returns an object with all of the item's property/value pairs. By default the object returned is a shallow copy of the stored data, but passing in true as the second parameter will return a reference to the stored data.
Parameters:
Returns:
remove
-
name
-
key
Removes a property from an item.
Properties
data
Unknown
Hash of attributes