-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making
RCTNetworking
js exports consistent (#48166)
Summary: Fixes #39260 Right now, there is a small issue when you try debugging the Networking library methods as it seems like they are empty in Android. This is not an actual functional issue as everything in code works fine, but rather an inconsistency in how the iOS and Android methods are being exported. In iOS it was exported as an object, in Android it was a class. ## Changelog: [INTERNAL] - Making `RCTNetworking` js exports consistent Pull Request resolved: #48166 Test Plan: I've checked that `XMLHttpRequest` is still working as expected, as this is used mostly there. And below there are screenshots of how the module methods are logged after the refactor. Which addresses what was reported in the linked issue. ```js import {Networking} from 'react-native'; import AndroidNetworking from 'react-native/Libraries/Network/RCTNetworking.android.js'; import IOSNetworking from 'react-native/Libraries/Network/RCTNetworking.ios.js'; console.log({Networking, AndroidNetworking, IOSNetworking}); ``` Before | After -- | -- <img width="1196" alt="image" src="https://github.com/user-attachments/assets/b7ab1dcd-9dd1-4ed9-ade5-d90251a77d5e"> | <img width="1196" alt="image" src="https://github.com/user-attachments/assets/5ae17c6a-b068-462a-b228-576dcf08ef12"> Reviewed By: fabriziocucci Differential Revision: D67022711 Pulled By: javache fbshipit-source-id: 81f9988295fb3f559a795077f09ee0f14827dc86
- Loading branch information
1 parent
6ba8b65
commit 9a21b99
Showing
5 changed files
with
96 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/react-native/Libraries/Network/RCTNetworkingEventDefinitions.flow.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
export type RCTNetworkingEventDefinitions = $ReadOnly<{ | ||
didSendNetworkData: [ | ||
[ | ||
number, // requestId | ||
number, // progress | ||
number, // total | ||
], | ||
], | ||
didReceiveNetworkResponse: [ | ||
[ | ||
number, // requestId | ||
number, // status | ||
?{[string]: string}, // responseHeaders | ||
?string, // responseURL | ||
], | ||
], | ||
didReceiveNetworkData: [ | ||
[ | ||
number, // requestId | ||
string, // response | ||
], | ||
], | ||
didReceiveNetworkIncrementalData: [ | ||
[ | ||
number, // requestId | ||
string, // responseText | ||
number, // progress | ||
number, // total | ||
], | ||
], | ||
didReceiveNetworkDataProgress: [ | ||
[ | ||
number, // requestId | ||
number, // loaded | ||
number, // total | ||
], | ||
], | ||
didCompleteNetworkResponse: [ | ||
[ | ||
number, // requestId | ||
string, // error | ||
boolean, // timeOutError | ||
], | ||
], | ||
}>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters