當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。