Method Overview
Name | Return Type | Summary | |
---|---|---|---|
Promise|Object | Convenience utility method to wait for a number of promises to either resolve or reject. more details | more details | |
Promise | Convenience utility method to create a promise that has been rejected with a provided error value. more details | more details | |
Promise | Convenience utility method to create a promise that will be resolved with a provided value. more details | more details |
Method Details
Convenience utility method to wait for a number of promises to either resolve or reject. The resulting promise resolves to an array of result objects containing the promise and either a value if the promise resolved, or an error if the promise rejected.
Parameter:Array of promises, or object where each property is a promise.
Returns:Type Description Promise | Object If called with an array of promises, resolves to an array of result objects containing the original promise and either a value (if the promise resolved) or an error (if the promise rejected). If called with an object where each property is a promise, then resolves to an object with the same properties where each property value is a result object. Example:// Query for the number of features from // multiple feature layers function queryLayerFeatureCount(whereClauses) { // pass each whereClause item into callback function return promiseUtils.eachAlways(whereClauses.map(function (whereClause) { return layer.queryFeatureCount(whereClause); })); }
reject(error){Promise}
Convenience utility method to create a promise that has been rejected with a provided error value.
Parameter:optionalerror ObjectThe error to reject the resulting promise with.
Returns:Type Description Promise A promise which is rejected with the provided error. Example:if (!data || !data.url) { return promiseUtils.reject(new Error("url is a required options property")); }
resolve(value){Promise}
Convenience utility method to create a promise that will be resolved with a provided value.
Parameter:optionalvalue *The value to resolve the resulting promise with.
Returns:Type Description Promise A promise which is resolved with the provided value. Example:// createGraphics will return a Promise that // resolves to graphics array function createGraphics() { var graphics = geoJson.features.map(function(feature, i) { return new Graphic({ geometry: new Point({ x: feature.geometry.coordinates[0], y: feature.geometry.coordinates[1] }), attributes: { ObjectID: i, title: feature.properties.title } }); }); return promiseUtils.resolve(graphics); }
Type Definitions
EachAlwaysResultObject
The result object for a promise passed to promiseUtils.eachAlways.
Properties:promise PromiseThe promise that has been fulfilled.
optionalvalue *The value with which the promise resolved. Defined only if the promise resolved.
optionalerror *The error with which the promise rejected. Defined only if the promise rejected.