[NodeJS] Promises and async/await
See original GitHub issueIt would be nice if there was a grpc-tools
and/or grpc_node_plugin
option that would generate client and server code that follows the ES6 Promise and ES7 async/await model.
For example, instead of: https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_client.js#L35-L37 We could write:
[err, response] = await client.sayHello(request);
Or something similar. On the server side, instead of: https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_server.js#L27-L31 We could write:
async function sayHello(call) {
var reply = new messages.HelloReply();
reply.setMessage('Hello ' + call.request.getName());
return [null, reply]
}
Again, just ideas.
This feature would eliminate the need for wrapper code for users wanting to use this pattern. I would love to know if anyone is interested in this feature or planning on adding it. Thanks!
(moved from https://github.com/grpc/grpc/issues/12751)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:185
- Comments:39 (8 by maintainers)
Promise is already must-have feature. For me callbacks are something from dawn of the dinosaurs 😃
Still no official support for async/await/Promises? This is a serious issue. People have been trying to not write callbacks in node for the last 5 years. Makes applications hard to read and maintain. Adding noisy promisify boilerplate everywhere is also not ideal. That plain looks like you are using legacy deprecated tech.