Yahoo! UI Library

attribute  3.3.0pr1

Yahoo! UI Library > attribute > State
Search:
 
Filters

Class State

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

Properties

data - object

Hash of attributes

Methods

add

void add ( name , key , val )
Adds a property to an item.
Parameters:
name <String> The name of the item.
key <String> The name of the property.
val <Any> The value of the property.

addAll

void addAll ( name , o )
Adds multiple properties to an item.
Parameters:
name <String> The name of the item.
o <Object> A hash of property/value pairs.

get

Any get ( name , key )
For a given item, returns the value of the property requested, or undefined if not found.
Parameters:
name <String> The name of the item
key <String> Optional. The property value to retrieve.
Returns: Any
The value of the supplied property.

getAll

Object getAll ( name )
For the given item, returns a disposable object with all of the item's property/value pairs.
Parameters:
name <String> The name of the item
Returns: Object
An object with property/value pairs for the item.

remove

void remove ( name , key )
Removes a property from an item.
Parameters:
name <String> The name of the item.
key <String> The property to remove.

removeAll

void removeAll ( name , o )
Removes multiple properties from an item, or remove the item completely.
Parameters:
name <String> The name of the item.
o <Object|Array> Collection of properties to delete. If not provided, the entire item is removed.


Copyright © 2010 Yahoo! Inc. All rights reserved.