當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。