InstanceManager Class
Stores instances of JavaScript components. Allows a constructor or factory method to be passed in place of an instance. This enables lazy construction on demand.
One use is to create a global repository of JavaScript components attached to DOM id's, e.g., YUI Buttons built on top of HTML buttons.
Constructor
InstanceManager
()
Item Index
Methods
Methods
applyToAll
-
behavior
-
arguments
-
skip_unconstructed
Call a function on every object.
Parameters:
-
behavior
Function | String | Objectthe function to call or the name of the function or an object {fn:,scope:}
-
arguments
Arraythe arguments to pass to the function
-
skip_unconstructed
BooleanOptional. Pass
true
to skip unconstructed slots.
clear
()
Remove all objects.
get
-
id
Retrieve an object.
Parameters:
-
id
Stringthe id of the object to retrieve
Returns:
the stored object, or false if the slot is empty
getIfConstructed
-
id
Retrieve an object only if it has already been constructed.
Parameters:
-
id
Stringthe id of the object to retrieve
Returns:
the stored object, or false if the slot is empty
keys
()
Returns list of all stored keys.
put
-
id
-
objOrCtor
-
args
Store an object or ctor+args.
Parameters:
-
id
Stringthe id of the object
-
objOrCtor
Object | Functionthe object or the object's constructor or a factory method
-
args
Arraythe array of arguments to pass to the constructor
Returns:
false if the id has already been used
remove
-
id
Remove an object.
Parameters:
-
id
Stringthe id of the object
Returns:
the object that was removed, or false if the slot was empty