React e gRPC com ReactRPC

O que é gRPC-web?

Conheça o ReactRPC!

const messages = require("../../helloworld_pb.js");
const clients = require("../../helloworld_grpc_web_pb.js");
const {improbRPC,googleRPC} = require("reactRPC");
reactRPC = googleRPC // ou reactRPC = improbRPCreactRPC.build(
messages,
clients,
"http://" + window.location.hostname + ":8080"
);
//proto filemessage fullName{
string firstName = 1;
string lastName = 2;}
//index.jsconst msg = {
firstName: "John",
lastName: "Doe",
msgType: "fullName"
}
//proto fileservice Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
}
//index.js
this.props.Greeter.sayHello(
message,
{},
(err, response) => {
console.log(response)
}
);

Links

Créditos

--

--

Senior Software Engineer @ Mintbase (https://rubenmarcus.dev)

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store