-
Notifications
You must be signed in to change notification settings - Fork 436
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
[Transport] React Native support - Adds and exposes ReactNativeTransport. #458
Conversation
} | ||
|
||
onLoadEvent(): void { | ||
const resp = this.xhr.response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this imply that the progress
event does not fire? It appears that you are only processing the response data when the XHR has completed (ie: when the loadend
event is fired).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, this event does not fire. #141 (comment) is a similar solution to what this PR tries to achieve, and this comment also mentions that this event is not being fired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying :)
Thanks for raising this @pbsf - if we are going to make this part of the @improbable-eng/grpc-web package then we will need to find a testing strategy to ensure it doesn't randomly break for consumers in future - is this something you can help with? |
@jonny-improbable, thank you for reviewing this PR. I had plans to add an example similar to But after your comment I noticed the integration_test folder. How about changing https://github.com/improbable-eng/grpc-web/blob/0c7a81a25d11e97972b5b6e6e61312fd7ad6413a/integration_test/ts/src/testRpcCombinations.ts by adding the introduced |
I think a test provides far more value, in terms of long term stability/maintainability than an example, so I would rather we start there. The integration tests were designed to be extended; much in the same way that the NodeHttpTransport is special cased. With regards to your implementation, one potential issue is that the progress event is still being listened for by the base XHR class which your After speaking with @MarcusLongmuir we both feel that this transport may be better implemented as a standalone package within this repo, in the same vein as the Please let me know your thoughts, and I'm happy to help :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- extract into a new package
- add integration tests
Hi @pbsf, please could you provide an update on the status of this PR? Thank you :) |
I was able to split the ArrayBufferXHR in its own package, but I'm having troubles to run the integration tests on my environment, thus I'm currently unable to add the integration tests needed. I ended up getting the Karma server to work, but after visiting localhost:9876 nothing happens. I installed the certificate on my browser. Do I need to do so on my OS as well? I created a Docker image to run the integration tests, and with it I can reproduce my issues. Once improved, that image can help others that wish to contribute to this project. I think that image should be on a separate pull request. |
@@ -0,0 +1,25 @@ | |||
# @improbable-eng/grpc-web-arraybufferxhr-transport | |||
ArrayBufferXHR Transport for use with [@improbable-eng/grpc-web](https://github.com/improbable-eng/grpc-web) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a good idea to suggest when/why someone might wish to use this transport. Also, perhaps grpc-web-react-native-transport
would be a more descriptive name?
I have cloned the repo and give that XHR transport a try and it's working! In our react native setup, we had used used this method in the past to fix I installed the package from local file and everything is working good. Thanks in advance to make it available in an official NPM package 😄 |
Hey @pbsf, please could you rename the package to |
@sebleclerc, I’m happy that this helped you! @jonny-improbable, I’ll do the renaming and resubmit tomorrow. I wasn’t able to run the integration tests as I mentioned on my comment above, though. |
Not a huge fan of the duplication; however we should be able to solve that by extracting |
this.init = init; | ||
} | ||
|
||
onProgressEvent() { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only thing I'm not happy with.
AFAIK this is the only change from the XHR class copied from transports/http/xhr.ts
which means it could easily be lost if we were ever de-dupliate the implementations.
Could you instead please restore the original onProgressEvent()
implementation here, mark the method as protected in this base XHR class, and then override it with an empty implementation in ArrayBufferXHR
implementation.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last change wrt avoiding potential future problems when refactoring and then we can land it.
@jonny-improbable, are there any more changes needed before merging this? Thanks. |
Sorry for the delay on this, I had hoped to land #539 first, but my time to contribute toward this package has dwindled over the last few months. |
It seems grpc-web-react-native-transport is pending for submission to npmjs. Meanwhile, any method to use reactnativetransport. I somehow need it urgently. See if anyone can help. Thanks. |
@consultchwong I did checkout the PR branch and point my |
I agree that a submission to npmjs would be great. I created #617 stating that. |
This revision adds and exposes a
ReactNativeTransport
, that uses anArrayBufferXhrTransport
. UsingArrayBufferXhrTransport
, React Native clients are able to work with gRPC-WEB.Verification
Manual verification with a React Native toy sample using Expo, which I intend to submit on a separate PR.