Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM] Add spec for Networking #24892

Closed

Conversation

thymikee
Copy link
Contributor

Summary

Part of #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

Test Plan

Flow passes.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner labels May 16, 2019
@react-native-bot react-native-bot added the Type: Enhancement A new feature or enhancement of an existing feature. label May 16, 2019
Copy link
Contributor

@ericlewis ericlewis left a comment

Choose a reason for hiding this comment

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

mostly looks good, but are we supposed to create 2 Specs? I think the aim is for a single Spec, then having bits that are iOS / Android specific commented.

Libraries/Network/NativeNetworkingIOS.js Outdated Show resolved Hide resolved
Libraries/Network/NativeNetworkingIOS.js Outdated Show resolved Hide resolved
callback: (requestId: number) => mixed,
) => void;
+abortRequest: (requestId: number) => void;
+clearCookies: (callback: (result: boolean) => mixed) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if mix is understood by the codegen, but i would err towards no.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rickhanlonii we need your powers here

Copy link
Member

Choose a reason for hiding this comment

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

Why does a callback have a return value?

I don't see any other usages of mixed like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing to void right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, this change. Please see this comment: #24892 (comment) what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RSNara could you please advise here? Is using mixed for callbacks supported by codegen? Or if we want users to be able to pass async callbacks we should return Promise<void> | void instead of just void?

Libraries/Network/NativeNetworkingAndroid.js Outdated Show resolved Hide resolved
import * as TurboModuleRegistry from 'TurboModuleRegistry';
import type {NativeResponseType} from './XMLHttpRequest';

type Header = [string, string];
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if Tuples are supported, should be interesting!

@ericlewis ericlewis added the Flow label May 16, 2019
@thymikee
Copy link
Contributor Author

mostly looks good, but are we supposed to create 2 Specs?

This is what we concluded with @rickhanlonii since there are 2 methods with different signatures, and Flow wasn't happy with Platform.OS branching. I'd be glad if someone can point a better solution :)

@rickhanlonii
Copy link
Member

Probably the best we can do until we unify the native interface to use the same prop types

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@fkgozali has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @thymikee in e8037cb.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label May 30, 2019
M-i-k-e-l pushed a commit to M-i-k-e-l/react-native that referenced this pull request Mar 10, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Flow Merged This PR has been merged. Native Module p: Callstack Partner: Callstack Partner Type: Enhancement A new feature or enhancement of an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants