API Docs for: 1.0.0
Show:

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

Methods

applyToAll

(
  • behavior
  • arguments
  • skip_unconstructed
)

Call a function on every object.

Parameters:

  • behavior Function | String | Object

    the function to call or the name of the function or an object {fn:,scope:}

  • arguments Array

    the arguments to pass to the function

  • skip_unconstructed Boolean

    Optional. Pass true to skip unconstructed slots.

clear

()

Remove all objects.

get

(
  • id
)
Mixed

Retrieve an object.

Parameters:

  • id String

    the id of the object to retrieve

Returns:

Mixed:

the stored object, or false if the slot is empty

getIfConstructed

(
  • id
)
Mixed

Retrieve an object only if it has already been constructed.

Parameters:

  • id String

    the id of the object to retrieve

Returns:

Mixed:

the stored object, or false if the slot is empty

keys

()

Returns list of all stored keys.

put

(
  • id
  • objOrCtor
  • args
)
Boolean

Store an object or ctor+args.

Parameters:

  • id String

    the id of the object

  • objOrCtor Object | Function

    the object or the object's constructor or a factory method

  • args Array

    the array of arguments to pass to the constructor

Returns:

Boolean:

false if the id has already been used

remove

(
  • id
)
Mixed

Remove an object.

Parameters:

  • id String

    the id of the object

Returns:

Mixed:

the object that was removed, or false if the slot was empty