registry
- Description:
Baja Type Registry.
At the core of BajaScript is a lazily loading Type and Contract
system. A Contract represents a frozen slot definition for a Complex
or a set of FrozenEnum ordinals, tags and display tags.The most commonly used Types are held in a Common Type Library that
is built into BajaScript to avoid unnecessary network calls.
- Source:
Methods
(static) getAgents(ords, isopt, batchopt) → {Promise}
- Description:
Make a query for an agent list. This can be made against
a type (i.e. 'type:moduleName:TypeName') or a BObject resolved
from an ORD (i.e. 'station:|slot:/MyComponent').If an array of ORDs is passed in the response will resolve with an Object.
Every key in that object will be an ORD String. Each value in the Object will
contain an array of Agent Info. An Agent Info object contains a 'typeSpec',
'id', 'displayName' and 'icon' String property. If a single
ORD was passed in then the response will be an array of Agent Infos.
- Source:
Examples
Get a Type's agent list.
baja.registry.getAgents("type:moduleName:TypeName")
.then(function (agentInfos) {
var i;
for (i = 0; i < agentInfos.length; ++i) {
console.log("typeSpec: " + agentInfos[i].typeSpec);
console.log("id: " + agentInfos[i].id);
console.log("displayName: " + agentInfos[i].displayName);
console.log("icon: " + agentInfos[i].icon);
}
});
Get the Agent List from a mounted Component.
baja.registry.getAgents("station:|slot:/Folder/MyComponent")
.then(function (agentInfos) {
var i;
for (i = 0; i < agentInfos.length; ++i) {
console.log("typeSpec: " + agentInfos[i].typeSpec);
console.log("id: " + agentInfos[i].id);
console.log("displayName: " + agentInfos[i].displayName);
console.log("icon: " + agentInfos[i].icon);
}
});
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ords |
String | baja.Ord | Array.<(String|baja.Ord)> | An ORD or a number of ORDs |
|
is |
Array.<String> |
<optional> |
An optional list of type specs to make a query against. |
batch |
baja.comm.Batch |
<optional> |
If specified, the request is batched. |
Returns:
A promise that will be resolved once completed.
- Type
- Promise
(static) getConcreteTypes(obj) → {Promise.<Array.<Type>>}
- Description:
Get an array of concrete Types from the given typeInfo. This method
will make a network call. The type information returned in the
ok handler may not necessarily have Contract information loaded.
To then ensure the Contract information for Complex and FrozenEnums
is loaded, please use baja.importTypes.
- Source:
- See:
Example
This method takes an object literal as an argument.
baja.registry.getConcreteTypes({
type: "control:ControlPoint",
batch: batch // If specified, network calls are batched into this object
})
.then(function (concreteTypes) {
baja.outln('got concrete types: ' + concreteTypes.join());
})
.catch(function (err) {
baja.error('failed to retrieve concrete types: ' + err);
});
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
obj |
Object | the Object literal for the method's arguments. Properties
|
Returns:
a promise that will be resolved
once the concrete Types have been retrieved.
- Type
- Promise.<Array.<Type>>
(static) hasType(typeSpec) → {Boolean}
- Description:
Does the Type exist in the BajaScript registry?
This method will not result in any network calls.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
typeSpec |
String | the type specification to query the registry for. |
Returns:
true if the Type exists in the BajaScript registry.
- Type
- Boolean
(static) importTypes()
- Description:
Same as baja.importTypes.
- Source:
- See: