Factoryable
Properties
3
Properties
3Class hierarchy
Functions
5
Functions
5Creates an instance from this factory, given the type name or a config object.
| Parameter | Type | Description |
|---|---|---|
config | String | Object | The type name string or config object. |
options | String | function | Object | Creation options (for details see reconfigure). |
Returns true if the passed instance is of the passed type or of a derived class.
| Parameter | Type | Description |
|---|---|---|
instance | Object | The object to test. |
type | String | The type to test against |
Returns true if the passed instance is of the passed type.
| Parameter | Type | Description |
|---|---|---|
instance | Object | The object to test. |
type | String | The type to test against |
deep | Boolean | Pass |
Reconfigures an optional existing instance based on the provided config and returns the correctly configured
instance. This will be the existingInstance if the config does not specify a different type.
If config is null (or simply falsy), this method will destroy the existingInstance (if any) and return
null.
If there is no existingInstance, the config must specify a type. That is, it must be a string (the type name)
or an object containing a type property, the defaultType must be provided or the factory itself must have
a defaultType specified (see factoryable).
When an existingInstance is provided and a type is specified, the instance will be reconfigured via setConfig
if it is of that type. Otherwise, the existingInstance is destroyed (if it is owned by the options.owner)
and a new instance of the correct type is created.
| Parameter | Type | Description |
|---|---|---|
existingInstance | Object | The instance to reconfigure. This can be |
config | String | Object | The type name string or config object. |
options | String | function | Object | Additional options to control the reconfiguration process. If this
value is a string or a class constructor, it treated as |
options.type | String | function | The default type to use if the |
options.owner | Object | The owner of any created instances. If the |
options.defaults | Object | A config object of default values to use when creating a new instance. |
options.setup | function | String | A function or the name of a method (on the |
options.transform | function | String | A function or the name of a method (on the |
options.cleanup | function | String | A function or the name of a method (on the |
The reconfigured instance (either existingInstance or a new instance of the desired type)
This method returns the constructor of the class registered for the given type name.
| Parameter | Type | Description |
|---|---|---|
type | String | The type name to look up. |
optional | Boolean | Pass |