当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS Histogram.when用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/widgets/Histogram"], (Histogram) => { /* code goes here */ });

ESM: import Histogram from "@arcgis/core/widgets/Histogram";

类: esri/widgets/Histogram

继承: Histogram > Widget > Accessor

自从:用于 JavaScript 4.12 的 ArcGIS API

用法说明

Histogram.when函数(或属性)的定义如下:

when (callback, errback) {Promise} inherited


自从:ArcGIS 适用于 JavaScript 4.19 的 API

一旦创建了类的实例,就可以利用when()。此方法采用两个输入参数:callback 函数和 errback 函数。 callback 在类实例加载时执行。 errback 如果类的实例无法加载,则执行。

参数:

类型说明
callback Function
可选的

当 promise 解决时调用的函数。

errback Function
可选的

当 promise 失败时执行的函数。

返回:

类型 说明
Promise callback 的结果返回一个新的承诺,该承诺可用于 chain 附加函数。

例子:

// Although this example uses the BasemapGallery widget, any class instance that is a promise may use when() in the same way
let bmGallery = new BasemapGallery();
bmGallery.when(function(){
  // This function will execute once the promise is resolved
}, function(error){
  // This function will execute if the promise is rejected due to an error
});

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 Histogram.when。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。