Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NodeJS] Promises and async/await #12751

Closed
alexkreidler opened this issue Sep 28, 2017 · 2 comments
Closed

[NodeJS] Promises and async/await #12751

alexkreidler opened this issue Sep 28, 2017 · 2 comments

Comments

@alexkreidler
Copy link

It 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:

client.sayHello(request, function(err, response) {
console.log('Greeting:', response.getMessage());
});

We could write:

  [err, response] = await client.sayHello(request);

Or something similar. On the server side, instead of:

function sayHello(call, callback) {
var reply = new messages.HelloReply();
reply.setMessage('Hello ' + call.request.getName());
callback(null, reply);
}

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!

@murgatroid99
Copy link
Member

Would you mind opening this against https://github.com/grpc/grpc-node? Going forward, that's where gRPC Node development will be, so it would be better to have this discussion there.

@alexkreidler
Copy link
Author

Moved to grpc/grpc-node#54

@lock lock bot locked as resolved and limited conversation to collaborators Oct 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants