本文整理汇总了TypeScript中bluebird.timeout函数的典型用法代码示例。如果您正苦于以下问题:TypeScript timeout函数的具体用法?TypeScript timeout怎么用?TypeScript timeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeout函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: waitForResponse
waitForResponse(request: ServiceRequest) : P<ServiceResponse> {
let responsePromise: P<ServiceResponse> = new P<ServiceResponse>((resolve) => {
var h = (msg) => {
console.log("Receive message", msg.type);
// Disconnect our listener
this.conn.removeListener('message', h);
if(msg.type === 'binary') {
console.log("Received binary message of len = ", msg.binaryData.length);
var response = this.protocolHandler.decode(msg.binaryData);
resolve(new BaseServiceResponse(response));
}
};
this.conn.on('message', h);
});
// Install the timeout for this request
responsePromise.timeout(request.options.timeout || 30000);
return responsePromise;
}
示例2: it
it('does not talk to you if are not authorized for the tribe requested', function (done) {
const socketPromise = new Bluebird((resolve, reject) => {
const options = {headers: this.authenticatedHeaders};
const websocket = new WebSocket(`ws://${server}/api/${unauthorizedTribe.id}/pairAssignments/current`, options);
websocket.on('close', resolve);
setupErrorHandler(websocket, reject);
});
socketPromise
.timeout(100)
.then(done, done.fail);
});
示例3:
fooProm.tapCatch(CustomError, (err: CustomError) => {
return err.customField;
});
fooProm.tapCatch((e: any) => e instanceof CustomError, (err: CustomError) => {
return err.customField;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.delay(num);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.timeout(num);
fooProm = fooProm.timeout(num, str);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm.nodeify();
fooProm = fooProm.nodeify((err: any) => { });
fooProm = fooProm.nodeify((err: any, foo?: Foo) => { });
fooProm.nodeify({ spread: true });
fooProm = fooProm.nodeify((err: any) => { }, { spread: true });
fooProm = fooProm.nodeify((err: any, foo?: Foo) => { }, { spread: true });
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// $ExpectType void