本文整理汇总了TypeScript中rxjs/observable/defer.defer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defer函数的具体用法?TypeScript defer怎么用?TypeScript defer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了defer函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should handle get packet error', fakeAsync(() => {
const searchResponse = new PcapStatusResponse();
searchResponse.jobId = '42';
pcapService.submitRequest = jasmine.createSpy('submitRequest').and.returnValue(
defer(() => Promise.resolve(searchResponse))
);
const pollResponse = new PcapStatusResponse();
pollResponse.jobStatus = 'SUCCEEDED';
pcapService.pollStatus = jasmine.createSpy('pollStatus').and.returnValue(
defer(() => Promise.resolve(pollResponse))
);
const restError = new RestError();
restError.responseCode = 500;
restError.message = 'error message';
pcapService.getPackets = jasmine.createSpy('getPackets').and.returnValue(
defer(() => Promise.reject(restError))
);
component.onSearch(new PcapRequest());
expect(component.errorMsg).toBeFalsy();
tick();
fixture.detectChanges();
expect(component.errorMsg).toEqual('Response message: error message. Something went wrong retrieving pdml results!');
}));
示例2: Actions
useFactory: (): Observable<any> => {
if (typeof factoryOrSource === 'function') {
return new Actions(defer(factoryOrSource));
}
return new Actions(factoryOrSource);
},