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


JavaScript ArcGIS watchUtils.PausableWatchHandle用法及代码示例


基本信息

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

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

ESM: import * as watchUtils from "@arcgis/core/core/watchUtils";

对象: esri/core/watchUtils

自从:用于 JavaScript 4.0 的 ArcGIS API

用法说明

watchUtils.PausableWatchHandle函数(或属性)的定义如下:

PausableWatchHandle Object


表示当对象调用 watch() 时创建的 watch 。

属性:

类型说明
remove Function

取下 watch 手柄。

pause Function

暂停句柄以防止更改调用关联的回调。

resume Function

恢复暂停的句柄。

例子:

let handle = watchUtils.pausable(map, 'basemap', function(newVal){
  // Each time the value of `map.basemap` changes, it is logged in the console
  console.log("new basemap: ", newVal);
});

// When pause() is called on the watch handle, the callback represented by the
// watch is no longer invoked, but is still available for later use
handle.pause();

// When resume() is called on the watch handle, the callback resumes
// firing each time the watched property changes.
handle.resume();

// When remove() is called on the watch handle, the map no longer watches for changes to basemap
handle.remove();

相关用法


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