new BatchResolve(ords)
BatchResolve is 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.
Parameters:
| Name | Type | Description |
|---|---|---|
ords |
Array.<baja.Ord> | an array of ORDs to resolve. |
Extends
Methods
-
<static> resolve(params)
-
Resolve an array of ORDs.
Parameters:
Name Type Description paramsObject parameters object. This may also be the array of
ORDs directly if no other parameters are required.Properties
Name Type Argument Description ordsArray.<(String|baja.Ord)> <optional>
the ORDs to resolve
basebaja.Object <optional>
the base Object to resolve the ORDs
against.subscriberbaja.Subscriber <optional>
if defined, any mounted
Components are subscribed using thisSubscriber.leaseBoolean <optional>
if defined, any resolved and mounted
components are leased.leaseTimeNumber | baja.RelTime <optional>
the lease time used for
leasingComponents.Returns:
promise to be resolved with a
BatchResolveinstance- Type
- Promise
Example
BatchResolve.resolve([ 'station:|slot:/foo', 'station:|slot:/bar' ]) .then(function (br) { var foo = br.get(0), bar = br.get(1); }); -
each(func)
-
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.Parameters:
Name Type Description funcfunction Throws:
-
thrown if any of the ORDs failed to resolve
- Type
- Error
-
-
equals(obj)
-
Indicates whether some other object is equal to this one.
Parameters:
Name Type Description objObject the reference object with which to compare.
- Inherited From:
Returns:
true if this object is the same as the obj argument; false otherwise.
- Type
- Boolean
-
get(index)
-
Return the resolved object at the specified index.
If the ORD failed to resolve, an error will be thrown.
Parameters:
Name Type Description indexNumber Throws:
-
thrown if the ORD failed to resolve
- Type
- Error
Returns:
the resolved object
- Type
- baja.Object
-
-
getFail(index)
-
Return the error for a particular ORD that failed to resolve or null for no error.
Parameters:
Name Type Description indexNumber Returns:
the error or null if no error.
- Type
- Error
-
getOrd(index)
-
Return the ORD at the specified index or null if the index is invalid.
Parameters:
Name Type Description indexNumber Returns:
- Type
- baja.Ord
-
getTarget(index)
-
Return the ORD Target at the specified index.
If the ORD failed to resolve, an error will be thrown.
Parameters:
Name Type Description indexNumber Throws:
-
thrown if ORD failed to resolve
- Type
- Error
Returns:
the ORD Target
-
-
getTargetObjects()
-
Return an array of resolved objects.
If any of the ORDs failed to resolve, an error will be thrown.
Throws:
-
thrown if any ORDs failed to resolve
- Type
- Error
Returns:
an array of objects
- Type
- Array.<baja.Object>
-
-
getTargets()
-
Return an array of resolved ORD Targets.
If any of the ORDs failed to resolve, an error will be thrown.
Throws:
-
thrown if any ORDs failed to resolve
- Type
- Error
Returns:
an array of ORD Targets
- Type
- Array.<module:baja/ord/OrdTarget>
-
-
isResolved(index)
-
Return true if the ORD at the specified index has successfully resolved.
Parameters:
Name Type Description indexNumber Returns:
- Type
- Boolean
-
resolve( [obj])
-
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.Parameters:
Name Type Argument Description objObject <optional>
the object literal that contains the method's
arguments.Properties
Name Type Argument Description okfunction <optional>
(Deprecated: use Promise) the ok function called
once all of the ORDs have been successfully resolved. When the function is
called,thisis set to theBatchResolveobject.failfunction <optional>
(Deprecated: use Promise) the fail function
called if any of the ORDs fail to resolve. The first error found is pass
as an argument to this function.basebaja.Object <optional>
the base Object to resolve the ORDs against.
subscriberbaja.Subscriber <optional>
if defined, any mounted
Components are subscribed using thisSubscriber.leaseBoolean <optional>
if defined, any resolved and mounted
components are leased.leaseTimeNumber | baja.RelTime <optional>
the lease time used for
leasingComponents.Returns:
a promise that will be resolved once the ORD resolution
is complete. The argument to thethencallback will be theBatchResolve
instance.- Type
- Promise
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 }); -
size()
-
Return the number of items in the Batch.
Returns:
- Type
- Number
-
valueOf()
-
Return the inner value of the object.
By default the object's instance is returned.
- Inherited From:
Returns:
the inner value of the object or just the object's instance.
- Type
- *