forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spec for Networking (facebook#24892)
Summary: Part of facebook#24875, adds a spec for Networking. Since `sendRequest` methods are different for both platforms, I had to create 2 spec files as Flow would merge their definitions even when I added `Platform.OS` check ## Changelog [General] [Added] - TM spec for Networking Pull Request resolved: facebook#24892 Reviewed By: RSNara Differential Revision: D15543067 Pulled By: fkgozali fbshipit-source-id: 2b91114dfa45e7899bbb139656a30a6fd52e31db
- Loading branch information
Showing
4 changed files
with
89 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {TurboModule} from 'RCTExport'; | ||
import * as TurboModuleRegistry from 'TurboModuleRegistry'; | ||
|
||
type Header = [string, string]; | ||
|
||
export interface Spec extends TurboModule { | ||
+sendRequest: ( | ||
method: string, | ||
url: string, | ||
requestId: number, | ||
headers: Array<Header>, | ||
data: Object, | ||
responseType: Object, // TODO: Use stricter type. | ||
useIncrementalUpdates: boolean, | ||
timeout: number, | ||
withCredentials: boolean, | ||
) => void; | ||
+abortRequest: (requestId: number) => void; | ||
+clearCookies: (callback: (result: boolean) => mixed) => void; | ||
|
||
// RCTEventEmitter | ||
+addListener: (eventName: string) => void; | ||
+removeListeners: (count: number) => void; | ||
} | ||
|
||
export default TurboModuleRegistry.getEnforcing<Spec>('Networking'); |
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,38 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {TurboModule} from 'RCTExport'; | ||
import * as TurboModuleRegistry from 'TurboModuleRegistry'; | ||
|
||
export interface Spec extends TurboModule { | ||
+sendRequest: ( | ||
query: {| | ||
method: string, | ||
url: string, | ||
data: Object, | ||
headers: Object, | ||
responseType: Object, // TODO: Use stricter type. | ||
incrementalUpdates: boolean, | ||
timeout: number, | ||
withCredentials: boolean, | ||
|}, | ||
callback: (requestId: number) => mixed, | ||
) => void; | ||
+abortRequest: (requestId: number) => void; | ||
+clearCookies: (callback: (result: boolean) => mixed) => void; | ||
|
||
// RCTEventEmitter | ||
+addListener: (eventName: string) => void; | ||
+removeListeners: (count: number) => void; | ||
} | ||
|
||
export default TurboModuleRegistry.getEnforcing<Spec>('Networking'); |
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