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


TypeScript PromiseWrapper.resolve方法代码示例

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


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

示例1: logs

 logs(type) {
   this._log.push(['logs', type]);
   if (type === 'performance') {
     return PromiseWrapper.resolve(this._events.map((event) => {
       return {
         'message': Json.stringify({'message': {'method': this._messageMethod, 'params': event}})
       };
     }));
   } else {
     return null;
   }
 }
开发者ID:1186792881,项目名称:angular,代码行数:12,代码来源:chrome_driver_extension_spec.ts

示例2: componentHandlerToComponentType

function componentHandlerToComponentType(handler): Promise<any> {
  var componentDeclaration = handler['component'], type = componentDeclaration['type'];

  if (type == 'constructor') {
    return PromiseWrapper.resolve(componentDeclaration['constructor']);
  } else if (type == 'loader') {
    var resolverFunction = componentDeclaration['loader'];
    return resolverFunction();
  } else {
    throw new BaseException(`Cannot extract the component type from a '${type}' component`);
  }
}
开发者ID:Salim-K,项目名称:angular,代码行数:12,代码来源:route_registry.ts

示例3: it

      it('should run Promise created in Promise', fakeAsync(() => {
           var log = new Log();

           PromiseWrapper.resolve(null).then((_) => {
             log.add(1);
             PromiseWrapper.resolve(null).then((_) => log.add(2));
           });

           expect(log.result()).toEqual('');

           flushMicrotasks();
           expect(log.result()).toEqual('1; 2');
         }));
开发者ID:1186792881,项目名称:angular,代码行数:13,代码来源:fake_async_spec.ts

示例4: logs

 logs(type) {
   this._log.push(['logs', type]);
   if (type === 'performance') {
     return PromiseWrapper.resolve(this._perfRecords.map(function(record) {
       return {
         'message': Json.stringify(
             {'message': {'method': 'Timeline.eventRecorded', 'params': {'record': record}}})
       };
     }));
   } else {
     return null;
   }
 }
开发者ID:1186792881,项目名称:angular,代码行数:13,代码来源:ios_driver_extension_spec.ts

示例5: _compileTemplate

  _compileTemplate(viewDef: ViewDefinition, tplElement,
                   protoViewType: number): Promise<ProtoViewDto> {
    var subTaskPromises = [];
    var pipeline = new CompilePipeline(this._stepFactory.createSteps(viewDef, subTaskPromises));
    var compileElements = pipeline.process(tplElement, protoViewType, viewDef.componentId);

    var protoView = compileElements[0].inheritedProtoView.build();

    if (subTaskPromises.length > 0) {
      return PromiseWrapper.all(subTaskPromises).then((_) => protoView);
    } else {
      return PromiseWrapper.resolve(protoView);
    }
  }
开发者ID:MiisterPatate,项目名称:planning,代码行数:14,代码来源:compiler.ts

示例6: _iterate

 _iterate(lastState): Promise<SampleState> {
   var resultPromise: Promise<any>;
   if (isPresent(this._prepare)) {
     resultPromise = this._driver.waitFor(this._prepare);
   } else {
     resultPromise = PromiseWrapper.resolve(null);
   }
   if (isPresent(this._prepare) || lastState.completeSample.length === 0) {
     resultPromise = resultPromise.then((_) => this._metric.beginMeasure());
   }
   return resultPromise.then((_) => this._driver.waitFor(this._execute))
       .then((_) => this._metric.endMeasure(isBlank(this._prepare)))
       .then((measureValues) => this._report(lastState, measureValues));
 }
开发者ID:LordBinary,项目名称:angular,代码行数:14,代码来源:sampler.ts

示例7: reportSample

 reportSample(completeSample: MeasureValues[], validSamples: MeasureValues[]): Promise<any> {
   this._printStringRow(this._metricNames.map((_) => ''), '=');
   this._printStringRow(this._metricNames.map(metricName => {
     var samples = validSamples.map(measureValues => measureValues.values[metricName]);
     var mean = Statistic.calculateMean(samples);
     var cv = Statistic.calculateCoefficientOfVariation(samples, mean);
     var formattedMean = ConsoleReporter._formatNum(mean)
                             // Note: Don't use the unicode character for +- as it might cause
                             // hickups for consoles...
                             return NumberWrapper.isNaN(cv) ?
                             formattedMean :
                             `${formattedMean}+-${Math.floor(cv)}%`;
   }));
   return PromiseWrapper.resolve(null);
 }
开发者ID:1186792881,项目名称:angular,代码行数:15,代码来源:console_reporter.ts

示例8: bootstrapRender

export function bootstrapRender(
    workerScriptUri: string,
    customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ApplicationRef> {
  var pf = ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM);
  var app = ReflectiveInjector.resolveAndCreate(
      [
        WORKER_RENDER_APPLICATION,
        /* @ts2dart_Provider */ {provide: WORKER_SCRIPT, useValue: workerScriptUri},
        isPresent(customProviders) ? customProviders : []
      ],
      workerRenderPlatform().injector);
  // Return a promise so that we keep the same semantics as Dart,
  // and we might want to wait for the app side to come up
  // in the future...
  return PromiseWrapper.resolve(app.get(ApplicationRef));
}
开发者ID:JavaScript-Resource,项目名称:angular,代码行数:16,代码来源:worker_render.ts

示例9: load

 load(template) {
   if (isPresent(template.inline)) {
     return PromiseWrapper.resolve(DOM.createTemplate(template.inline));
   }
   var url = template.absUrl;
   if (isPresent(url)) {
     var promise = StringMapWrapper.get(this._htmlCache, url);
     if (isBlank(promise)) {
       promise = this._xhr.get(url).then(function(html) {
         var template = DOM.createTemplate(html);
         return template;
       });
       StringMapWrapper.set(this._htmlCache, url, promise);
     }
     return promise;
   }
   throw new BaseException('Templates should have either their url or inline property set');
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:18,代码来源:template_loader.ts


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