-
debounce
(callback)
{Function}
static
- 自從:ArcGIS 適用於 JavaScript 4.12 的 API
用於確保輸入函數一次不會同時被多次調用的實用程序。這對於高度交互的應用程序很有用,例如對 mouse-move 或 mouse-drag 事件執行統計查詢的應用程序。您可以"debounce" 或取消函數執行,而不是對每個此類事件執行查詢,直到相同函數調用的先前執行完成。這提高了此類應用程序的性能和用戶體驗。
參數:
類型 說明 callback Function防止在執行對同一函數的先前調用期間執行的函數。這通常是可以在 mouse-move 或 mouse-drag 事件上調用的函數。
返回:
類型 說明 Function 與回調具有相同簽名的函數。 例子:
// Queries a layer for the count of features that intersect a // 1 km buffer of the pointer location. The debounce() method // prevents the updateStatistics function from executing before // a previous invocation of the same function finishes. const updateStatistics = promiseUtils.debounce(function (geometry) { return layerView.queryFeatures({ geometry, distance: 1, units: "kilometers", outStatistics: [{ onStatisticField: "*", outStatisticFieldName: "feature_count", statisticType: "count" }] }).then(function(featureSet) { console.log(`Feature Count: ${featureSet.features[0].attributes["feature_count"]}`); }); }); view.on("drag", (event) => updateStatistics(view.toMap(event)));
基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/core/promiseUtils"], (promiseUtils) => { /* code goes here */ });
ESM:
import * as promiseUtils from "@arcgis/core/core/promiseUtils";
對象:
esri/core/promiseUtils
自從:用於 JavaScript 4.2 的 ArcGIS API
用法說明
promiseUtils.debounce
函數(或屬性)的定義如下:
相關用法
- JavaScript ArcGIS promiseUtils.eachAlways用法及代碼示例
- JavaScript ArcGIS promiseUtils.isAbortError用法及代碼示例
- JavaScript ArcGIS promiseUtils.create用法及代碼示例
- JavaScript ArcGIS promiseUtils.resolve用法及代碼示例
- JavaScript ArcGIS promiseUtils.reject用法及代碼示例
- JavaScript ArcGIS promiseUtils.createAbortError用法及代碼示例
- JavaScript promise reject()用法及代碼示例
- JavaScript ArcGIS projection.load用法及代碼示例
- JavaScript ArcGIS projection.getTransformations用法及代碼示例
- JavaScript ArcGIS projection.project用法及代碼示例
- JavaScript ArcGIS predominance.createRenderer用法及代碼示例
- JavaScript ArcGIS print.execute用法及代碼示例
- JavaScript ArcGIS predominantCategories.predominantCategories用法及代碼示例
- JavaScript ArcGIS predominance.getSchemeByName用法及代碼示例
- JavaScript ArcGIS predominanceUtils.getPredominanceExpressions用法及代碼示例
- JavaScript ArcGIS predominance.cloneScheme用法及代碼示例
- JavaScript ArcGIS predominance.getSchemes用法及代碼示例
- JavaScript ArcGIS predominance.getSchemesByTag用法及代碼示例
- JavaScript parseInt()用法及代碼示例
- JavaScript parseFloat()用法及代碼示例
- JavaScript performance.now()用法及代碼示例
- JavaScript ArcGIS SceneView double-click事件用法及代碼示例
- JavaScript ArcGIS geometryEngineAsync.overlaps用法及代碼示例
- JavaScript ArcGIS Expand.when用法及代碼示例
- JavaScript ArcGIS Sublayer.JoinTableDataSource用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 promiseUtils.debounce。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。