-
Notifications
You must be signed in to change notification settings - Fork 10
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
Updated deprecated NetInfo usage #52
Conversation
So I’ve been busy this past few weeks but I’m trying to make space this weekend to test this and work on other stuff that’s pending. Just wanted to let you know. Thanks |
Hey Guys, Thanks for the PR, When can this be merged? @sorodrigo |
@wacii this introduces a breaking change because the Before the API So shall we make a breaking change bump on next release? EDIT: As an alternative the methods can be updated to use latest |
Sounds good. Eventually I would like to move the defaults into their own package/s to isolate these changes, as this obviously doesn't affect the library when used on the web. But that is for another time. The |
@wacii I was just looking to the source code for that exact same reason. To see where it was actually used or exposed. And yes, it is part of the NetInfo in the store, but it's still an internal implementation detail as far as I can see, so I think it's not a breaking change to the public interface. |
@kbrandwijk It doesn't change the interface but won't this code no longer work with older versions of React Native? |
@wacii I agree. If there is a policy for version support, I can make it support n-2 or something. Changes would include case-insensitivity of connectionType, and fallback to use the old methods if the new ones are not available. |
Perhaps the best solution is to include another default (something like |
It would be unclear for me how those would automagically be linked together. How would that work? |
It wouldn't, if we want to make it automagically best I can think of is: // detectNetwork.native.legacy.js
export default DetectNetwork;
// detectNetwork.native.js
import LegacyDetectNetwork from './detectNetwork.native.legacy.js'
/* new code */
const isLegacy = typeof NetInfo.getConnectionInfo === 'undefined';
export default callback => (isLegacy ? LegacyDetectNetwork(callback) : DetectNetwork(callback)) I'm open to other suggestions. |
Although that would lead to some code duplication, I guess it's better indeed to keep the two implementations isolated from each other, so it can easily be deprecated later on. |
Do you want to do something to normalize connectionTypes across the two implementations, or should the RN connectionTypes be leading? I would prefer the latter. |
I think the way it is now is just fine. 🤙 |
Fixes #39.
fetch()
->getConnectionInfo()
change
->connectionChange