本文整理汇总了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; });
});
示例2: removeItem
removeItem(key) {
if (this.storageBackend) {
return PromiseWrapper.wrap(() => this.storageBackend.removeItem(key))
} else {
return PromiseWrapper.resolve("")
}
}
示例3: setItem
setItem(key, value) {
if (this.storageBackend) {
return PromiseWrapper.wrap(() => this.storageBackend.setItem(key, value))
} else {
return PromiseWrapper.resolve("")
}
}
示例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();
});
}));
示例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);
});
}
示例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);
});
}
示例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)});
});
示例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;
});
示例9: expect
broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => {
expect(arg1).toEqual(PASSED_ARG_1);
return PromiseWrapper.wrap(() => { return RESULT; });
});
示例10: _echo
private _echo(val: string) {
return PromiseWrapper.wrap(() => { return val; });
}