gnolang / gnonative

Develop for Gno using your app's native language
Apache License 2.0
9 stars 9 forks source link

feat: add react-native streams support #55

Closed D4ryl00 closed 9 months ago

D4ryl00 commented 9 months ago

This PR adds the stream function to the React-Native gRPC transport. Because the fetch API is not fully implemented in React-Native (see issue here), I had to polyfill the missing fetch function (package here) and replaced some functions in the global namespace (see here).

On Android, text-streaming doesn't work out-of-the-box on the debug variant. One solution is to comment the NetworkFlipperPlugin (see here). Because we don't use it for the moment, I commented that plugin.

I added a HelloStream API function to test the stream feature. We can call it in Reac-Native by doing this:

for await (const res of clientInstance.helloStream(new HelloStreamRequest({ name: 'd4ryl00' }))) {
  console.log(res.greeting);
}