当前位置:网站首页>ArcGIS JS customizes the accessor and uses the watchutils related method to view the attribute
ArcGIS JS customizes the accessor and uses the watchutils related method to view the attribute
2022-07-28 07:36:00 【No overrun】
Technical requirements : Use watchUtils class ,whenTrue Related methods , Monitoring properties .
Business needs : Map class library , You need to read an interface of the intranet , Judge whether the network is an intranet , In order to access more map resources in the intranet server in the Intranet environment . Plan to pass a logo , adopt xhr Set the ID after requesting the interface . after , Map related functions , Judge the variable before execution , Is it true, Prevent some variables from failing to complete initialization due to asynchrony .
Customize Accessor class
/**
* 20220727
* Map initialization object monitoring It is mainly used to record whether the map initialization work is completed
*/
import Accessor from "esri/core/Accessor";
import { property, subclass } from "esri/core/accessorSupport/decorators";
@subclass("custom.MO")
class MO extends Accessor {
private isOK: boolean = false;
constructor() {
super();
this.isOK = false;
}
@property()
get isIni(): boolean {
return this.isOK;
}
set isIni(val: boolean) {
const oldValue = this.get<boolean>("isIni");
if (oldValue !== val) {
// a setter has to update the value from the cache
// this.set("isIni", val);
this.isOK = val;
this.notifyChange("isIni");
}
}
}
export = MO;
Examples used in the main function
import watchUtils = require("esri/core/watchUtils");
watchUtils.whenTrue(this.mo, "isIni", () => {
if (tp == "layerlist") {
if (collapsed) t.expandLayerList.collapse();
else t.expandLayerList.expand();
}
if (tp == "legend") {
if (collapsed) {
t.expandLegend.collapse();
} else {
t.expandLegend.expand();
}
}
});It is important to avoid the pit , An exception occurred during the test :

It has been suspected that there is a problem with the custom class , As a result, the attribute is not obtained , A lot of information , There are many different ways of writing . Finally, I suddenly remembered my previous post ,
ArcGIS JS TypeScript urlUtils Use of _ No overrun blog -CSDN Blog
take import watchUtils from "" Writing , Change to
import watchUtils = require("")
After testing , It can be realized normally .
official ArcGIS JS Accessor class
Implementing Accessor | Overview | ArcGIS API for JavaScript 4.24 | ArcGIS Developers
边栏推荐
- Student duty problems
- 辨析覆盖索引/索引覆盖/三星索引
- EMC rectification method set
- Map uses tuple to realize multiple value values
- Dry goods | share an EMC actual case and rectification process
- EMC's "don't come back until you rectify"
- Niuke MySQL - SQL must know and know
- 细说共模干扰和差模干扰
- How low-end computers learn secrets in depth - using the mistgpu computing platform
- .NET 6.0中使用Identity框架实现JWT身份认证与授权
猜你喜欢

DNA-CuInSeQDs近红外CuInSe量子点包裹脱氧核糖核酸DNA

The cornerstone of EMC - complete knowledge of electromagnetic compatibility filtering!

Redis的RDB持久化和AOF持久化的底层原理

深入剖析单例模式的实现

cdn.jsdelivr.net不可用,该怎么办

近红外二区AgzS量子点包裹脱氧核糖核酸DNA|DNA-AgzSQDs(齐岳)

CAS vs Database optimistic lock

辨析覆盖索引/索引覆盖/三星索引

Learning to estimate 3D hand pose from single RGB image & amp notes

细说共模干扰和差模干扰
随机推荐
Summary of RFID radiation test
4.1.4为什么要将成员变量设置为private
JS upload file method
Summary of project experience
Collector原理解析
JS secondary linkage Department
【无标题】
Adjust the array order so that odd numbers precede even numbers - two questions per day
Short work priority SJF
项目经历总结
链表中倒数第k个节点——双指
MySQL基础知识学习(二)
Activate function
EMC rectification ideas
DNA脱氧核糖核酸修饰金属铂纳米颗粒PtNPS-DNA|科研试剂
磁环选型攻略及EMC整改技巧
铜铟硫CuInSe2量子点修饰DNA(脱氧核糖核酸)DNA-CuInSe2QDs(齐岳)
和为s的两个数字——每日两题
Log in to heroku and the solution of IP address mismatch appears
Continous Gesture Recognition with hand-orented spatiotemporal feature