zoukankan      html  css  js  c++  java
  • ArcGIS JsAPI 模块化技术演变过程

    4.12

    主题:API Modernization

    官方进行了几次API更新,使得API能在现代浏览器中发挥更好的作用。

    • 源代码的93%使用 TypeScript 编写

    • esri/request 现在使用原生的 FetchAPI 实现;如果不支持 FetchAPI,则使用 fetch polyfill 代替

    • 大多数异步方法现在支持一个 AbortSignal 类的可选参数:signal,具体详见:Asynchronous Method Cancellation

    • 使用一个 has 属性来标记是否使用原生的 Promise。当前,异步函数返回一个 Dojo 的 Promise,如果使用这个标记,那么将返回原生 Promise 对象。

      var dojoConfig = {
          has: {
              "esri-native-promise": true
          }
      }
      

    4.13

    主题:API Modernization

    • 96%的源代码使用 TypeScript 编写
    • 官方打算在下一版本中默认使用原生的 Promise,而且在 4.15 版本中完全移除 Dojo Promise. 当前版本想默认使用官方的 Promise,参考 4.12 中的 has 属性用法。

    官方做了一些准备工作,以消除 Dojo 模块化机制。当前版本中,模块化是使用 dojo/_base/declare 实现的,官方正在迁移到 ES模块(或者说TS模块)。

    迁移的第一步,是停止使用多重继承,并使用混合模式。见帮助文档:实现Accessor

    4.14

    官方打算在 4.15 版本默认使用原生 Promise(好像鸽了上一版本的计划),在 4.16 则完全移除 Dojo Promise 的依赖。

    4.15

    两项改动。

    esriConfig 可作为全局变量

    现在,可以使用全局的 esriConfig 对象来设置 esri/config 属性。

    <script>
      var esriConfig = {
        portalUrl: "https://myHostName.esri.com/arcgis"
      };
    </script>
    

    返回原生 Promise

    此版本默认使用原生的 Promise 对象,下一版本移除对 Dojo Promise 的支持。这意味着:

    • 不再使用 otherwise() 方法,用 catch() 代替
    • 不再使用 cancel() 方法,使用 AbortController.abort() 代替
    • 不再使用 always() 方法,使用下列 then() 链代替:
    .catch(function(error){
      /* do something with the error */
    }).then(function() {
      /* this function is always executed */
    });
    
    • 没有 isFulfilled()/isResolved()/isReject() 方法了

    注意,原生 Promise 对 then/catch 使用的是异步,而 Dojo Promise 使用的是同步。

    dojo 声明

    下一版本中,dojo的 declare 将完全移除。

    这意味着,多继承的支持,4.15是最后一版。当前版本会报一个警告信息。

    4.16

    在 2020 年 Esri 开发者峰会上,官方宣布了要对 JS API 进行改造,以便与现代前端框架、开发工具集成。当前增强的功能有:

    • 原生 Promise 是默认使用的,has 属性中的 esri-native-promise 属性已经不再支持(见4.12)
    • 本地化已改善,主要是使用 intl.setLocale() 方法,有关这个主题的更多信息,见:Localization
    • 现在已经使用原生的模块化来代替 dojo/_base/declare
    • 多继承不再支持
    • 当前旧的类语法仍然支持,但是很快就被丢弃了。建议:
      • 移除 amd-dependency 注释
      • tsconfig.json 添加 importHelpers: ture
      • 移除对 Dojo declare 的使用

    下面是一些语法对比。

    之前的ts语法

    /// <amd-dependency path="esri/core/tsSupport/declareExtendsHelper" name="__extends" />
    /// <amd-dependency path="esri/core/tsSupport/decorateHelper" name="__decorate" />
    
    import Accessor = require("esri/core/Accessor");
    
    import { subclass, declared } from "esri/core/accessorSupport/decorators";
    
    @subclass("esri.guide.Color")
    class Color extends declared(Accessor) {
    }
    

    新的ts语法

    import Accessor = require("esri/core/Accessor");
    
    import { subclass } from "esri/core/accessorSupport/decorators";
    
    @subclass("esri.guide.Color")
    class Color extends Accessor {
    }
    

    4.17

    在 4.16 中已经不推荐使用 IE11 和 旧 edge 浏览器了,4.17是支持他们的最后一版。

    ES模块 - 开发中

    现在这个进程还在进行中,还不能投入生产。官方打算在 4.18 发布一个beta的生产版本,在2021年初会剪面。

  • 相关阅读:
    lecture 11.4
    lecture 10.30
    boolean functions and beyon
    lecture10.21
    golang hex to string
    golang中 将string转化为json
    ubuntu16报错: add-apt-repository command not found
    ubuntu16的防火墙关闭
    ubuntu 16 解决错误 manpath: can't set the locale; make sure $LC_* and $LANG are correct
    go get 安装时报 (https fetch: Get https://golang.org/x/crypto/acme/autocert?go-get=1: dial tcp 220.255.2.153:443: i/o timeout)
  • 原文地址:https://www.cnblogs.com/onsummer/p/13784626.html
Copyright © 2011-2022 走看看