Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Fix message streaming using react-native-community/fetch #8

Merged
merged 6 commits into from
Dec 16, 2022

Conversation

elisealix22
Copy link
Contributor

@elisealix22 elisealix22 commented Dec 15, 2022

This PR demonstrates streaming messages in a Conversation. The issue was React Native's fetch implementation doesn't support streaming with body.

Related RN issue and RN feature request to upvote.

The feature request led me to Realm's workaround realm/realm-js#4155 which was extremely helpful as it pointed me to use text type instead of blob in https://github.com/react-native-community/fetch. However, we can't pass the: { reactNative: { textStreaming: true } } to fetch itself like it's recommended since our fetch methods are auto-generated in the https://github.com/xmtp/proto repo. To workaround that, I patched the default type to text instead of blob which I believe should be ok since it appears it can still be overridden in the options.

Here's the motivation behind using text for streaming to begin with: https://github.com/react-native-community/fetch#motivation.

NOTE: This only resolves streaming on iOS. Android streaming is still under investigation.

Relates to: xmtp/xmtp-js#223

Demo

demo_streaming.mov

Testing steps

  • Ensure streaming works with a random wallet address
  • Re-test sign in and ensure streaming works with my authenticated address
  • Stream on iOS
  • Stream on Android

Copy link

@nplasterer nplasterer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on iOS and works great. Down with merging this as is and iterate on Android in a follow up. 👍

@elisealix22
Copy link
Contributor Author

Updated the description to indicate this only resolves streaming on iOS. Android is still under investigation 👀

@elisealix22 elisealix22 merged commit e45645a into main Dec 16, 2022
@elisealix22 elisealix22 deleted the ea/fix-stream branch December 16, 2022 02:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants