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


TypeScript PromiseWrapper.wrap方法代码示例

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


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

示例1: expect

 .andCallFake((args: UiArguments, returnType: Type) => {
   expect(args.type).toEqual("xhr");
   expect(args.method).toEqual("get");
   expect(args.args.length).toEqual(1);
   expect(args.args[0].value).toEqual(URL);
   return PromiseWrapper.wrap(() => { return RESPONSE; });
 });
开发者ID:lavinjj,项目名称:angular,代码行数:7,代码来源:xhr_impl_spec.ts

示例2: removeItem

 removeItem(key) {
     if (this.storageBackend) {
         return PromiseWrapper.wrap(() => this.storageBackend.removeItem(key))
     } else {
         return PromiseWrapper.resolve("")
     }
 }
开发者ID:cm0s,项目名称:mea2n,代码行数:7,代码来源:localStorage.ts

示例3: setItem

 setItem(key, value) {
     if (this.storageBackend) {
         return PromiseWrapper.wrap(() => this.storageBackend.setItem(key, value))
     } else {
         return PromiseWrapper.resolve("")
     }
 }
开发者ID:cm0s,项目名称:mea2n,代码行数:7,代码来源:localStorage.ts

示例4: it

 it('should throw for non components', inject([AsyncTestCompleter], (async) => {
      PromiseWrapper.catchError(PromiseWrapper.wrap(() => compile([NonComponent])), (error) => {
        expect(error.message)
            .toEqual(
                `Could not compile '${stringify(NonComponent)}' because it is not a component.`);
        async.done();
      });
    }));
开发者ID:TedSander,项目名称:angular,代码行数:8,代码来源:template_compiler_spec.ts

示例5: createExtension

 function createExtension(ids: any[], caps) {
   return PromiseWrapper.wrap(() => {
     return ReflectiveInjector.resolveAndCreate([
                                ids.map(id => provide(id, {useValue: new MockExtension(id)})),
                                bind(Options.CAPABILITIES).toValue(caps),
                                WebDriverExtension.bindTo(ids)
                              ])
         .get(WebDriverExtension);
   });
 }
开发者ID:844496869,项目名称:angular,代码行数:10,代码来源:web_driver_extension_spec.ts

示例6: createExtension

 function createExtension(ids, caps) {
   return PromiseWrapper.wrap(() => {
     return Injector.resolveAndCreate([
                      ListWrapper.map(ids, (id) => bind(id).toValue(new MockExtension(id))),
                      bind(Options.CAPABILITIES).toValue(caps),
                      WebDriverExtension.bindTo(ids)
                    ])
         .get(WebDriverExtension);
   });
 }
开发者ID:cedriclam,项目名称:angular,代码行数:10,代码来源:web_driver_extension_spec.ts

示例7: _createAppInjector

  zone.run(() => {
    // TODO(rado): prepopulate template cache, so applications with only
    // index.html and main.js are possible.

    var appInjector = _createAppInjector(appComponentType, componentInjectableBindings, zone);
    var compRefToken: Promise<any> =
        PromiseWrapper.wrap(() => appInjector.get(appComponentRefToken));
    var tick = (componentRef) => {
      var appChangeDetector = internalView(componentRef.hostView).changeDetector;
      // retrieve life cycle: may have already been created if injected in root component
      var lc = appInjector.get(LifeCycle);
      lc.registerWith(zone, appChangeDetector);
      lc.tick();  // the first tick that will bootstrap the app

      bootstrapProcess.resolve(new ApplicationRef(componentRef, appComponentType, appInjector));
    };
    PromiseWrapper.then(compRefToken, tick,
                        (err, stackTrace) => {bootstrapProcess.reject(err, stackTrace)});
  });
开发者ID:cedriclam,项目名称:angular,代码行数:19,代码来源:application.ts

示例8: expect

 .andCallFake((args: UiArguments, returnType: Type) => {
   expect(args.method).toEqual(methodName);
   if (isPresent(vals)) {
     expect(args.args.length).toEqual(vals.length);
     ListWrapper.forEachWithIndex(vals, (v, i) => {expect(v).toEqual(args.args[i].value)});
   }
   var promise = null;
   if (isPresent(handler)) {
     let givenValues = args.args.map((arg) => {arg.value});
     if (givenValues.length > 0) {
       promise = handler(givenValues);
     } else {
       promise = handler();
     }
   }
   if (promise == null) {
     promise = PromiseWrapper.wrap(() => {});
   }
   return promise;
 });
开发者ID:ProjectFrank,项目名称:angular,代码行数:20,代码来源:web_worker_test_util.ts

示例9: expect

 broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => {
   expect(arg1).toEqual(PASSED_ARG_1);
   return PromiseWrapper.wrap(() => { return RESULT; });
 });
开发者ID:1186792881,项目名称:angular,代码行数:4,代码来源:service_message_broker_spec.ts

示例10: _echo

 private _echo(val: string) {
   return PromiseWrapper.wrap(() => { return val; });
 }
开发者ID:ASLA1899,项目名称:angular,代码行数:3,代码来源:index_common.ts


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