new BatchResolve(ords)
- Description:
BatchResolveis used to resolve a list of ORDs together.This method should always be used if multiple ORDs need to be resolved at
the same time.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
ords |
Array.<baja.Ord> | an array of ORDs to resolve. |
Extends
Methods
each(func)
- Description:
For each resolved target, call the specified function.
If any ORDs failed to resolve, an error will be thrown.
When the function is called, the
thiswill be the resolved
Component's target. The target's object will be passed as a parameter
into the function.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
func |
function |
Throws:
-
thrown if any of the ORDs failed to resolve
- Type
- Error
equals(obj) → {Boolean}
- Description:
Indicates whether some other object is equal to this one.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | the reference object with which to compare. |
Returns:
true if this object is the same as the obj argument; false otherwise.
- Type
- Boolean
get(index) → {baja.Object}
- Description:
Return the resolved object at the specified index.
If the ORD failed to resolve, an error will be thrown.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number |
Throws:
-
thrown if the ORD failed to resolve
- Type
- Error
Returns:
the resolved object
- Type
- baja.Object
getFail(index) → {Error}
- Description:
Return the error for a particular ORD that failed to resolve or null for no error.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number |
Returns:
the error or null if no error.
- Type
- Error
getOrd(index) → {baja.Ord}
- Description:
Return the ORD at the specified index or null if the index is invalid.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number |
Returns:
- Type
- baja.Ord
getTarget(index) → {module:baja/ord/OrdTarget}
- Description:
Return the ORD Target at the specified index.
If the ORD failed to resolve, an error will be thrown.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number |
Throws:
-
thrown if ORD failed to resolve
- Type
- Error
Returns:
the ORD Target
getTargetObjects() → {Array.<baja.Object>}
- Description:
Return an array of resolved objects.
If any of the ORDs failed to resolve, an error will be thrown.
- Source:
Throws:
-
thrown if any ORDs failed to resolve
- Type
- Error
Returns:
an array of objects
- Type
- Array.<baja.Object>
getTargets() → {Array.<module:baja/ord/OrdTarget>}
- Description:
Return an array of resolved ORD Targets.
If any of the ORDs failed to resolve, an error will be thrown.
- Source:
Throws:
-
thrown if any ORDs failed to resolve
- Type
- Error
Returns:
an array of ORD Targets
- Type
- Array.<module:baja/ord/OrdTarget>
isResolved(index) → {Boolean}
- Description:
Return true if the ORD at the specified index has successfully resolved.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
index |
Number |
Returns:
- Type
- Boolean
resolve(objopt) → {Promise}
- Description:
Batch resolve an array of ORDs.
A Batch Resolve should be used whenever more than one ORD needs to resolved.
Any network calls that result from processing an ORD are always asynchronous.
This method can only be called once per BatchResolve instance.
When using promises, the static
BatchResolve.resolvefunction will be
a little cleaner.
- Source:
- See:
Example
var r = new baja.BatchResolve(["station:|slot:/Ramp", "station:|slot:/SineWave"]);
var sub = new baja.Subscriber(); // Also batch subscribe all resolved Components
r.resolve({ subscriber: sub })
.then(function () {
// Get resolved objects
var obj = r.getTargetObjects();
})
.catch(function (err) {
// Called if any of the ORDs fail to resolve
});
// Or use the each method (will only be called if all ORDs resolve). Each will
// be called for each target.
r.resolve({
each: function () {
baja.outln("Resolved: " + this.toPathString());
},
subscriber: sub
});
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
obj |
Object |
<optional> |
the object literal that contains the method's Properties
|
Returns:
a promise that will be resolved once the ORD resolution
is complete. The argument to the then callback will be the BatchResolve
instance.
- Type
- Promise
size() → {Number}
- Description:
Return the number of items in the Batch.
- Source:
Returns:
- Type
- Number
valueOf() → {*}
- Description:
Return the inner value of the object.
By default the object's instance is returned.
- Source:
- Inherited From:
Returns:
the inner value of the object or just the object's instance.
- Type
- *
(static) resolve(params) → {Promise}
- Description:
Resolve an array of ORDs.
- Source:
Example
BatchResolve.resolve([ 'station:|slot:/foo', 'station:|slot:/bar' ])
.then(function (br) {
var foo = br.get(0), bar = br.get(1);
});
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | parameters object. This may also be the array of Properties
|
Returns:
promise to be resolved with a BatchResolve instance
- Type
- Promise