Fixed MongoDBCollection#watch on React Native#4155
Conversation
| ], | ||
| "env": { | ||
| "es2017": true | ||
| "es2020": true |
There was a problem hiding this comment.
This is needed to be able to use the globalThis keyword and should be okay for the platforms we support.
| ], | ||
| }, | ||
| { | ||
| input: "src/react-native/index.ts", |
There was a problem hiding this comment.
We're adding a new "react-native" bundle to separate the code that runs on "react-native" from that which run on web.
| // Setting this non-standard option to enable text streaming | ||
| // See https://github.com/react-native-community/fetch#enable-text-streaming | ||
| DefaultNetworkTransport.extraFetchOptions = { | ||
| reactNative: { textStreaming: true }, |
There was a problem hiding this comment.
See https://github.com/react-native-community/fetch#enable-text-streaming for details on why we're adding this.
There was a problem hiding this comment.
It's already there - two lines above the line I commented on here :)
| try { | ||
| // We'll await the response to catch throw our own error | ||
| return await DefaultNetworkTransport.fetch(url, { | ||
| ...DefaultNetworkTransport.extraFetchOptions, |
There was a problem hiding this comment.
I tried setting this only on the streaming requests, but that yield the following in my test app:
LOG Running "ReactNativeTestApp" with {"rootTag":61,"initialProps":{}}
WARN Invalid responseType: blob
ERROR {"code": -1, "message": "undefined is not an object (evaluating 'options.blobId')"}
WARN Invalid responseType: blob
LOG Unable to symbolicate stack trace: undefined is not an object (evaluating 'options.blobId')
WARN Invalid responseType: blob
WARN Invalid responseType: blob
WARN Invalid responseType: blob
c985b88 to
460ab84
Compare
| // Setting this non-standard option to enable text streaming | ||
| // See https://github.com/react-native-community/fetch#enable-text-streaming | ||
| DefaultNetworkTransport.extraFetchOptions = { | ||
| reactNative: { textStreaming: true }, |
takameyer
left a comment
There was a problem hiding this comment.
Awesome. Do we need to prominently document this somewhere, besides in the comments?
Besides the changes I'm proposing to the TypeScript docs and JSDoc, I would say the instructions on adding the babel plugin and globals polyfill needs to be inserted on https://docs.mongodb.com/realm/sdk/react-native/examples/query-mongodb/#real-time-change-notifications as well. |
What, How & Why?
This closes #3494 by adding documentation on installing polyfills and a babel plugin, plus calling the React Native fetch polyfill with the right option.
If the user forgets to add the polyfill and calls
watch()TypeScript documentation as seen in VC Code
The JSDoc documentation
☑️ ToDos
Compatibilitylabel is updated or copied from previous entryBreakinglabel has been applied or is not necessaryIf this PR adds or changes public API's: