File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
packages/react-native/src/sync/stream Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @powersync/react-native ' : minor
3+ ---
4+
5+ Added ability to use Expo's fetch API if available.
Original file line number Diff line number Diff line change @@ -27,7 +27,24 @@ export const STREAMING_POST_TIMEOUT_MS = 30_000;
2727 * a polyfill.
2828 */
2929class ReactNativeFetchProvider extends FetchImplementationProvider {
30+ constructor ( public logger : ILogger = DEFAULT_REMOTE_LOGGER ) {
31+ super ( ) ;
32+ }
33+
3034 getFetch ( ) : FetchImplementation {
35+ /**
36+ * From Expo 52, Expo provides a fetch implementation which supports HTTP streams.
37+ * https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api
38+ */
39+ try {
40+ const f = require ( 'expo/fetch' ) . fetch ;
41+ if ( f ) {
42+ this . logger . debug ( 'Using Expo fetch implementation' ) ;
43+ return f ;
44+ }
45+ } catch ( e ) {
46+ // If expo is not installed, fallback
47+ }
3148 return fetch . bind ( globalThis ) ;
3249 }
3350}
@@ -40,7 +57,7 @@ export class ReactNativeRemote extends AbstractRemote {
4057 ) {
4158 super ( connector , logger , {
4259 ...( options ?? { } ) ,
43- fetchImplementation : options ?. fetchImplementation ?? new ReactNativeFetchProvider ( )
60+ fetchImplementation : options ?. fetchImplementation ?? new ReactNativeFetchProvider ( logger )
4461 } ) ;
4562 }
4663
You can’t perform that action at this time.
0 commit comments