ProAct.Registry Class
src/js/dsl/registry.js:9
Constructs a ProAct.Registry
.
It is used to store/create objects that can be referenced or configured using the ProAct.DSL.
ProAct.Registry
is part of the proact-dsl
module of ProAct.js.
Constructor
ProAct.Registry
()
Item Index
Properties
Methods
get
-
name
Retrieves an object, stored this registry.
getProviderByName is used to locate the right provider to retrieve the object from.
Parameters:
-
name
StringName of the object to find.
It must be in the format '{namespace}:{key}'
Returns:
The stored object, or null if there was no ProAct.Registry.Provider register for its type or no object registered for the passed name.
getProviderByName
-
name
Retrieves the right ProAct.Registry.Provider using the name of stored in this ProAct.Registry object, or the name of an object to be stored
Parameters:
-
name
StringThe name of storable object.
It must be in the format '{namespace}:{key}'.
Here the namespace is the namespace the ProAct.Registry.Provider manages.
Returns:
The first element in the result is the ProAct.Registry.Provider or undefined if not found.
The second one is the key at which an object is stored or will be stored in the provider.
The third element is an array with options for storing/creating an object passed to the provider using the name string.
make
-
name
-
options
-
[...]
Creates a new object and stores it in this registry, using the right provider for the creation and configuring it using the DSL passed through the options parameter.
getProviderByName is used to locate the right provider to create the object with.
setup is used to setup the newly created object using the ProAct.DSL
The idea of this method is to create and configure ProAct.Actor objects.
Parameters:
-
name
StringName of the object to create and store.
It must be in the format '{namespace}:{key}'
-
options
String | ObjectA ProAct.DSL data object or string used to setup the object to be created.
-
[...]
#crossLink "ProAct.DSL/run:method" optionalArguments to be used by the }{{/crossLink}} method while configuring the newly created object.
Returns:
The newly created, stored and configured object, or null if there was no ProAct.Registry.Provider register for its type.
register
-
namespace
-
provider
Registers a ProAct.Registry.Provider for the passed namespace in the registry.
Parameters:
-
namespace
StringThe namespace to register the provider in.
-
provider
ProAct.Registry.ProviderThe ProAct.Registry.Provider to register.
Returns:
this
setup
-
object
-
options
-
args
Configures an object to be stored using ProAct.DSL passed through options and DSL arguments.
Example usage:
A ProAct.Stream is passed to the registry for setup with DSL data.
The data passed through the options parameter is
'<<(s:foo)|map(-)|filter($1)'
And the arguments for the DSL machine passed through the args parameter are
[function (v) { return v % 2 === 0; }]
This means that a ProAct.Stream stored in this registry by the key 'foo' should be set as a source to the passed as the object parameter simple ProAct.Stream.
It also means that for every value comming in the object parameter's stream there should be mapping of negativity and only even values should be passed to it.
So if we trigger in the 'foo' stream the value of 4 in our stream we will get -4, and if we trigger 5, we won't get anything.
Parameters:
-
object
ObjectThe object to setup.
-
options
String | ObjectA ProAct.DSL data object or string used to setup the object.
-
args
ArrayArguments to be used by the ProAct.DSL/run:method method while configuring the passed object.
Returns:
Ready to strore object.
store
-
name
-
object
-
options
-
[...]
Stores an object in this registry, using the right provider to configure it using the DSL passed through the options parameter.
getProviderByName is used to locate the right provider to store the object to.
Parameters:
-
name
StringName of the object to store.
It must be in the format '{namespace}:{key}'
-
object
ObjectThe object to store.
-
options
String | ObjectA ProAct.DSL data object or string used to setup the object to be stored (optional).
-
[...]
#crossLink "ProAct.DSL/run:method" optionalArguments to be used by the }{{/crossLink}} method while configuring the object.
Returns:
The stored and configured object, or null if there was no ProAct.Registry.Provider register for its type.
toObject
-
data
Helper method for transforming a key of stored item in this ProAct.Registry
to the actual item or returning the key, if
the item is not found in the ProAct.Registry
.
Mainly used by the ProAct.DSL logic.
Parameters:
Returns:
Stored object, if found using the passed data or the data itself.
toObjectArray
-
array
Helper method for transforming an array of keys of stored items in this ProAct.Registry
to an array of the actual items.
Mainly used by the ProAct.DSL logic.
Parameters:
Returns:
Of the retrieved objects, in the same order as the keys.