EarthSDK
    正在准备搜索索引...

    函数 cancelableFetchDeprecated

    • 可取消可监视进度的fetch

      参数

      • progressFunc: undefined | ((loaded: number, total: number) => void)

        用来获取下载的进度信息

      • ...args: [input: string | URL | Request, init?: RequestInit]

        原始fetch的参数

      返回 [(cancelError?: CancelError) => void, Promise<Response>]

    • 可取消可监视进度的fetch

      参数

      • setCancelOrCancelResult: CancelResult | SetCancelFunc
      • progressFunc: undefined | ((loaded: number, total: number) => void)

        用来获取下载的进度信息

      • ...args: [input: string | URL | Request, init?: RequestInit]

        原始fetch的参数

      返回 Promise<Response>

      const cancelResult: CancelResult = {};
      const progressFunc = (loaded: number, total: number) => {
      console.log(`loaded: ${loaded} total: ${total} p: ${(loaded/total)*100 | 0}`);
      }

      console.log('revocableFetch');
      revocableFetch(cancelResult, progressFunc, 'http://earthsdk.com/t/videoModels/qiangji/3/obj/3.obj').then(response => {
      if (response.ok) {
      console.log('ok');
      }
      return response.text();
      }).then(text => {
      console.log(text);
      }).catch(error => {
      console.log(error);
      });