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


TypeScript PromiseWrapper.all方法代码示例

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


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

示例1: compile

 function compile(components: Type[]): Promise<any[]> {
   return PromiseWrapper.all(components.map(normalizeComponent))
       .then((normalizedCompWithViewDirMetas: NormalizedComponentWithViewDirectives[]) => {
         var sourceModule = compiler.compileTemplatesCodeGen(normalizedCompWithViewDirMetas);
         var sourceWithImports =
             testableTemplateModule(sourceModule,
                                    normalizedCompWithViewDirMetas[0].component)
                 .getSourceWithImports();
         return evalModule(sourceWithImports.source, sourceWithImports.imports, null);
       });
 }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: inject

           inject([AsyncTestCompleter, XHR], (async, xhr: MockXHR) => {
             xhr.expect('package:angular2/test/core/compiler/compUrl.html', 'a');
             PromiseWrapper.all([compile([CompWithTemplateUrl]), compile([CompWithTemplateUrl])])
                 .then((humanizedTemplates) => {
                   expect(humanizedTemplates[0]['commands'][1]['commands']).toEqual(['#text(a)']);
                   expect(humanizedTemplates[1]['commands'][1]['commands']).toEqual(['#text(a)']);

                   async.done();
                 });
             xhr.flush();
           }));
开发者ID:,项目名称:,代码行数:11,代码来源:

示例3: normalizeComponent

 function normalizeComponent(component: Type):
     Promise<NormalizedComponentWithViewDirectives> {
   var compAndViewDirMetas = [runtimeMetadataResolver.getMetadata(component)].concat(
       runtimeMetadataResolver.getViewDirectivesMetadata(component));
   return PromiseWrapper.all(compAndViewDirMetas.map(
                                 meta => compiler.normalizeDirectiveMetadata(meta)))
       .then((normalizedCompAndViewDirMetas: CompileDirectiveMetadata[]) =>
                 new NormalizedComponentWithViewDirectives(
                     normalizedCompAndViewDirMetas[0],
                     normalizedCompAndViewDirMetas.slice(1)));
 }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例4: inject

           inject([AsyncTestCompleter], (async) => {
             var one = PromiseWrapper.completer();

             var all = PromiseWrapper.all([one.promise, abruptCompletion]);

             PromiseWrapper.then(all, (val) => {
               expect(val[1]).toEqual(abruptCompletion);
               async.done();
             });

             one.resolve('one');
           }));
开发者ID:hankduan,项目名称:angular,代码行数:12,代码来源:async_spec.ts

示例5: sample

  sample({id, execute, prepare, microMetrics, bindings}): Promise<SampleState> {
    var sampleBindings = [
      _DEFAULT_PROVIDERS,
      this._defaultBindings,
      bind(Options.SAMPLE_ID).toValue(id),
      bind(Options.EXECUTE).toValue(execute)
    ];
    if (isPresent(prepare)) {
      sampleBindings.push(bind(Options.PREPARE).toValue(prepare));
    }
    if (isPresent(microMetrics)) {
      sampleBindings.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
    }
    if (isPresent(bindings)) {
      sampleBindings.push(bindings);
    }

    var inj = Injector.resolveAndCreate(sampleBindings);
    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 = Injector.resolveAndCreate([
            sampleBindings,
            bind(Options.CAPABILITIES).toValue(capabilities),
            bind(Options.USER_AGENT).toValue(userAgent),
            provide(WebDriverAdapter, {useValue: adapter})
          ]);

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

示例6: it

      it("should combine lists of Promises", inject([AsyncTestCompleter], (async) => {
           var one = PromiseWrapper.completer();
           var two = PromiseWrapper.completer();

           var all = PromiseWrapper.all([one.promise, two.promise]);
           var allCalled = false;

           PromiseWrapper.then(one.promise, (_) => {
             expect(allCalled).toBe(false);
             two.resolve('two');
             return null;
           });

           PromiseWrapper.then(all, (_) => {
             allCalled = true;
             async.done();
             return null;
           });

           one.resolve('one');
         }));
开发者ID:hankduan,项目名称:angular,代码行数:21,代码来源:async_spec.ts

示例7: reportSample

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

示例8: reportMeasureValues

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

示例9: 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:hankduan,项目名称:angular,代码行数:9,代码来源:multi_metric.ts

示例10: beginMeasure

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


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