pomelo icon indicating copy to clipboard operation
pomelo copied to clipboard

pomelo rpc调用能支持Promise吗?

Open codeorg opened this issue 7 years ago • 6 comments

 async send(msg,session,next){

	 session.set('uid',msg.uid)
	let p1_res=await this.app.rpc.chat.chatRemote.p1(session, msg, msg);

	next(null, {code: 200, msg: p1_res});
}

目前实现方法都是callback,希望开发组与时俱进支持Promise

codeorg avatar Mar 29 '17 05:03 codeorg

。。。这个,我建议你还是自己包装吧。而且,既然要求支持 Promise,干嘛示例代码用 async/await

zyf0330 avatar Mar 29 '17 09:03 zyf0330

Promise可以直接被await Promose()。 我要实现的是 this.app.rpc.chat.chatRemote.p1 这个函数的

codeorg avatar Mar 29 '17 13:03 codeorg

强烈建议修改pomelo 库里handlerService.js 的handler 改用Promise,不然每个类都要实现一次,虽然可以继承

codeorg avatar Mar 29 '17 13:03 codeorg

估计V3的时候,就这样了~

bugs1111 avatar May 16 '17 09:05 bugs1111

自己将 prototype的方法 异步, image 结果 image

deferClass 方法 image

heibaikn avatar Jul 06 '18 03:07 heibaikn

@node-pinus 可以了解一下。

whtiehack avatar Jul 06 '18 03:07 whtiehack