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


TypeScript bluebird.timeout函数代码示例

本文整理汇总了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;
    } 
开发者ID:Covistra,项目名称:cmbf2,代码行数:26,代码来源:response-handler.ts

示例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);
    });
开发者ID:robertfmurdock,项目名称:Coupling,代码行数:12,代码来源:websocket-spec.ts

示例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
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:30,代码来源:bluebird-tests.ts


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