当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript PromiseWrapper.all方法代码示例

本文整理汇总了TypeScript中@angular/facade.PromiseWrapper.all方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PromiseWrapper.all方法的具体用法?TypeScript PromiseWrapper.all怎么用?TypeScript PromiseWrapper.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/facade.PromiseWrapper的用法示例。


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

示例1: sample

  sample({id, execute, prepare, microMetrics, providers, userMetrics}:
             {id: string, execute?: any, prepare?: any, microMetrics?: any, providers?: any, userMetrics?: any}):
      Promise<SampleState> {
    var sampleProviders = [
      _DEFAULT_PROVIDERS,
      this._defaultProviders,
      {provide: Options.SAMPLE_ID, useValue: id},
      {provide: Options.EXECUTE, useValue: execute}
    ];
    if (isPresent(prepare)) {
      sampleProviders.push({provide: Options.PREPARE, useValue: prepare});
    }
    if (isPresent(microMetrics)) {
      sampleProviders.push({provide: Options.MICRO_METRICS, useValue: microMetrics});
    }
    if (isPresent(userMetrics)) {
      sampleProviders.push({provide: Options.USER_METRICS, useValue: userMetrics});
    }
    if (isPresent(providers)) {
      sampleProviders.push(providers);
    }

    var inj = ReflectiveInjector.resolveAndCreate(sampleProviders);
    var adapter = inj.get(WebDriverAdapter);

    return PromiseWrapper
        .all([adapter.capabilities(), adapter.executeScript('return window.navigator.userAgent;')])
        .then((args) => {
          var capabilities = args[0];
          var userAgent = args[1];

          // This might still create instances twice. We are creating a new injector with all the
          // providers.
          // Only WebDriverAdapter is reused.
          // TODO vsavkin consider changing it when toAsyncFactory is added back or when child
          // injectors are handled better.
          var injector = ReflectiveInjector.resolveAndCreate([
            sampleProviders,
            {provide: Options.CAPABILITIES, useValue: capabilities},
            {provide: Options.USER_AGENT, useValue: userAgent},
            {provide: WebDriverAdapter, useValue: adapter}
          ]);

          var sampler = injector.get(Sampler);
          return sampler.sample();
        });
  }
开发者ID:4vanger,项目名称:angular,代码行数:47,代码来源:runner.ts

示例2: reportSample

 reportSample(completeSample: MeasureValues[], validSample: MeasureValues[]): Promise<any[]> {
   return PromiseWrapper.all(
       this._reporters.map(reporter => reporter.reportSample(completeSample, validSample)));
 }
开发者ID:4vanger,项目名称:angular,代码行数:4,代码来源:multi_reporter.ts

示例3: reportMeasureValues

 reportMeasureValues(values: MeasureValues): Promise<any[]> {
   return PromiseWrapper.all(
       this._reporters.map(reporter => reporter.reportMeasureValues(values)));
 }
开发者ID:4vanger,项目名称:angular,代码行数:4,代码来源:multi_reporter.ts

示例4: endMeasure

 /**
  * Ends measuring and reports the data
  * since the begin call.
  * @param restart: Whether to restart right after this.
  */
 endMeasure(restart: boolean): Promise<{[key: string]: any}> {
   return PromiseWrapper.all(this._metrics.map(metric => metric.endMeasure(restart)))
       .then(values => mergeStringMaps(values));
 }
开发者ID:0xJoKe,项目名称:angular,代码行数:9,代码来源:multi_metric.ts

示例5: beginMeasure

 /**
  * Starts measuring
  */
 beginMeasure(): Promise<any> {
   return PromiseWrapper.all(this._metrics.map(metric => metric.beginMeasure()));
 }
开发者ID:0xJoKe,项目名称:angular,代码行数:6,代码来源:multi_metric.ts


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