• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript maybe-promise.MaybePromise类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中lib/classes/maybe-promise.MaybePromise的典型用法代码示例。如果您正苦于以下问题:TypeScript MaybePromise类的具体用法?TypeScript MaybePromise怎么用?TypeScript MaybePromise使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MaybePromise类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: showNotification

  private showNotification(request: RedirectRequest): MaybePromise<void> {
    this.debugLog.log("going to show a redirection notification");
    const browser = this.requestService.getBrowser(request);
    if (browser === null) {
      this.debugLog.log("showNotification: browser n/a");
      return MaybePromise.reject<void>(undefined);
    }

    const window = browser.ownerGlobal;

    const p = tryMultipleTimes(() => {
      const windowModule = this.windowModuleMap.get(window);
      if (!windowModule) {
        this.debugLog.log("showNotification: window module n/a");
        return false;
      }

      // Parameter "replaceIfPossible" is set to true,
      // because the "origin" of
      // redirections going through "nsIChannelEventSink" is just an
      // intermediate URI of a redirection chain, not a real site.
      return windowModule.r21n.showNotification(
          browser,
          {
            origin: request.originURI,
            target: request.destURIWithRef,
          },
          0,
          true,
      );
    });
    return MaybePromise.resolve(p);
  }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:33,代码来源:redirection-service.ts


示例2: startupSelf

 protected startupSelf() {
   this.addRulePopup = this.windowService.$id(
       this.window,
       addRuleMenuName,
   ) as any;
   return MaybePromise.resolve(undefined);
 }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:7,代码来源:redirection-notifications.ts


示例3: startupSelf

 public startupSelf() {
   const manifestUrl = this.chromeFileService.
       getChromeUrl("bootstrap-data/manifest.json");
   const p = this.chromeFileService.parseJSON(manifestUrl).then((data) => {
     this.data = data;
   });
   return MaybePromise.resolve(p);
 }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:8,代码来源:manifest.ts


示例4: startupSelf

  protected startupSelf() {
    if (this.cachedSettings.get("browserSettings.disableNetworkPrediction")) {
      this.networkPrivacyApi.networkPredictionEnabled.set({value: false}).catch(
          this.log.onError("set networkPredictionEnabled false"),
      );
    } else {
      this.networkPrivacyApi.networkPredictionEnabled.clear({}).catch(
          this.log.onError("clear networkPredictionEnabled setting"),
      );
    }

    return MaybePromise.resolve(undefined);
  }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:13,代码来源:browser-settings.module.ts


示例5: startupSelf

  protected startupSelf() {
    // create a scope variable
    (this.window as any).rpcontinued = {
      classicmenu: this.classicmenu,
      menu: this.menu,
      overlay: this.overlay,
    };

    this.xulTreeLists_ = this.xulService.getXulTreeLists(this.overlay);

    // add all XUL elements
    this.xulService.addTreeElementsToWindow(
        this.window,
        this.xulTreeLists.mainTree,
    );

    return MaybePromise.resolve(undefined);
  }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:18,代码来源:xul-trees.ts


示例6: it

    it("it's synchronous when all() is called with empty list", function() {
      // setup
      let thenFnCalled = false;
      let catchFnCalled = false;

      // exercise
      const mp = MaybePromise.all([]);
      mp.then(() => {
        thenFnCalled = true;
        return;
      }, () => {
        catchFnCalled = true;
      });

      // verify
      assert.strictEqual(thenFnCalled, true);
      assert.strictEqual(catchFnCalled, false);
    });
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:18,代码来源:test-maybe-promise.ts


示例7: genMaybePromise

function genMaybePromise({isFulfilled, isPromiseWrapper, value = {}, usingAllFn = false}): MaybePromise<any> {
  const mpArg = isPromiseWrapper ? genPromise({isFulfilled, value}) : (value as any);
  const mp = isPromiseWrapper || isFulfilled ?
      MaybePromise.resolve(mpArg) : MaybePromise.reject(mpArg);
  return usingAllFn ? MaybePromise.all([mp]) : mp;
}
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:6,代码来源:test-maybe-promise.ts


示例8: startupSelf

 protected startupSelf() {
   return MaybePromise.resolve(this.startupSelfAsync());
 }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:3,代码来源:settings-migration.ts


示例9: startupSelf

 protected startupSelf() {
   this.addToolbarButtonToAustralis();
   return MaybePromise.resolve(undefined);
 }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:4,代码来源:toolbarbutton.australis.ts


示例10: startupSelf

  protected startupSelf() {
    const promises: IInfoPromises = {};

    const checkPromise = (aPropName: keyof IInfoPromises) => {
      (promises[aPropName] as Promise<any>).catch((e) => {
        this.log.error(`Error initializing "${aPropName}":`, e);
      });
    };

    const infos: IOptionalInfos = {};

    // -------------------------------------------------------------------------
    // RP version info
    // -------------------------------------------------------------------------

    promises.lastRPVersion = Promise.resolve(
        this.cachedSettings.get("lastVersion") as IInfos["lastRPVersion"],
    );
    checkPromise("lastRPVersion");

    promises.isRPUpgrade =
        promises.lastRPVersion.
        then((lastRPVersion) => {
          // Compare with version 1.0.0a8 since that version introduced
          // the "welcome window".
          infos.isRPUpgrade = !!lastRPVersion &&
              this.versionComparator.compare(lastRPVersion, "1.0.0a8") <= 0;
          return infos.isRPUpgrade;
        });
    checkPromise("isRPUpgrade");

    promises.curRPVersion =
        this.managementApi.getSelf().
        then((addon) => {
          infos.curRPVersion = addon.version;
          return infos.curRPVersion;
        });
    checkPromise("curRPVersion");

    // -------------------------------------------------------------------------
    // app version info
    // -------------------------------------------------------------------------

    promises.lastAppVersion = Promise.resolve(
        this.cachedSettings.get("lastAppVersion") as IInfos["lastAppVersion"],
    );
    checkPromise("lastAppVersion");

    promises.curAppVersion =
        this.runtimeApi.getBrowserInfo().
        then(({version}) => {
          infos.curAppVersion = version;
          return version;
        });
    checkPromise("curAppVersion");

    // -------------------------------------------------------------------------
    // store last*Version
    // -------------------------------------------------------------------------

    const p = Promise.all(
        objectValues(promises as IObject<Promise<any>>),
    ).then(() => {
      this.infos = infos as IInfos;
      const {curAppVersion, curRPVersion} = infos;
      return this.cachedSettings.set({
        lastAppVersion: curAppVersion,
        lastVersion: curRPVersion,
      });
    }).catch((e) => {
      this.log.error("Failed to initialize VersionInfoService", e);
    }) as Promise<void>;

    return MaybePromise.resolve(p);
  }
开发者ID:RequestPolicyContinued,项目名称:requestpolicy,代码行数:75,代码来源:version-info-service.ts



注:本文中的lib/classes/maybe-promise.MaybePromise类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript date.exhibitionPeriod函数代码示例发布时间:2022-05-25
下一篇:
TypeScript log.Log类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap