new MultiLoader(loaders)
Constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
loaders |
Array.<Loader> | array of loader objects |
- Version:
-
- 1.1.0
Example
const filter1 = new DatumFilter();
filter1.nodeId = 123;
// configure other filter settings here...
const filter2 = new DatumFilter();
filter2.nodeId = 234;
// configure other filter settings here
const urlHelper = new NodeDatumUrlHelper();
new MultiLoader([
new DatumLoader(urlHelper, filter1),
new DatumLoader(urlHelper, filter2),
]).load((error, results) => {
// results is a 2-element array of Datum arrays
});
Members
-
<static, readonly> version :string
-
The class version.
Type:
- string
Methods
-
callback( [value])
-
Get or set the callback function, invoked after all data has been loaded. The callback function will be passed two arguments: an error and the results as an array of results from each configured
Loader.Parameters:
Name Type Argument Description valueMultiLoader~dataCallback <optional>
the callback function to use
Returns:
when used as a getter, the current callback function, otherwise this object
-
concurrency( [value])
-
Get or set the concurrency limit to use for requets.
A default, infinite concurrency queue will be used by default.
Parameters:
Name Type Argument Description valuenumber <optional>
the concurrency level to use, or
Infinityfor no limit- Since:
-
- 1.1.0
Returns:
when used as a getter, the current concurrency value, otherwise this object
- Type
- number | MultiLoader
-
fetch()
-
Asynchronously load the data.
This method calls
MultiLoader#loadto perform the actual work.Returns:
the result promise
- Type
- Promise.<Array.<Object>>
-
load( [callback])
-
Initiate loading the data. This will call
Loader#loadon each supplied loader, in parallel. As an alternative to configuring the callback function via theMultiLoader#callbackmethod, a callback function can be passed as an argument to this function. This allows this function to be passed toqueue.defer, for example.Parameters:
Name Type Argument Description callbackMultiLoader~dataCallback <optional>
a callback function to use; either this argument must be provided or the function must have already been configured via
MultiLoader#callbackReturns:
this object
- Type
- MultiLoader
Type Definitions
-
dataCallback( [error], data)
-
The data callback function.
Parameters:
Name Type Argument Description errorError <optional>
an error if a failure occurred
dataArray.<Object> the result data from all loaders