diff --git a/README.md b/README.md index a1e6601..dea66b5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ npm install @mitch528/react-native-grpc ## Usage -```js +```ts import { GrpcClient, GrpcMetadata } from '@mitch528/react-native-grpc'; GrpcClient.setHost('example.com'); @@ -18,11 +18,11 @@ GrpcClient.setHost('example.com'); // Bring your own protobuf library // This example uses https://github.com/timostamm/protobuf-ts -const message = ExampleMessage.create({ +const request = ExampleRequest.create({ message: 'Hello World!', }); -const data: Uint8Array = ExampleMessage.toBinary(message); +const data: Uint8Array = ExampleRequest.toBinary(request); const headers: GrpcMetadata = {}; const { response } = await GrpcClient.unaryCall( diff --git a/example/src/App.tsx b/example/src/App.tsx index d24c413..b43661e 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,9 +1,9 @@ +import { GrpcClient } from '@mitch528/react-native-grpc'; import 'fast-text-encoding'; import React, { useEffect, useState } from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import { GrpcClient } from '@mitch528/react-native-grpc'; import { RNGrpcTransport } from './transport'; -import { ExampleMessage, ExamplesClient } from './_proto/example'; +import { ExampleRequest, ExamplesClient } from './_proto/example'; export default function App() { const [result, setResult] = useState(); @@ -13,13 +13,13 @@ export default function App() { GrpcClient.setInsecure(true); const client = new ExamplesClient(new RNGrpcTransport()); - const message = ExampleMessage.create({ + const request = ExampleRequest.create({ message: 'Hello World', }); const abort = new AbortController(); - const unaryCall = client.sendExampleMessage(message, { + const unaryCall = client.sendExampleMessage(request, { abort: abort.signal, });