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

[iOS] RX.Network.getType() regression with RN 0.57.2 #850

Closed
luisnaranjo733 opened this issue Oct 9, 2018 · 1 comment
Closed

[iOS] RX.Network.getType() regression with RN 0.57.2 #850

luisnaranjo733 opened this issue Oct 9, 2018 · 1 comment

Comments

@luisnaranjo733
Copy link
Member

I have a WIP migration from RN 0.55 to 0.57. In this branch I'm noticing that the promise returned from RX.Network.getType() never gets resolved the first time it is called. If I add a second call to getType() will sometimes result in either the first promise being resolved or the second one (never both, but sometimes neither).

Example code

function networkStateChanged(networkState: RX.Types.DeviceNetworkType) {
  console.log(`network state changed: ${networkState}`;
}

RX.Network.connectivityChangedEvent.subscribe(isConnected => {
  if (isConnected) {
    RX.Network.getType() .then(networkStateChanged); // never resolves
  }
});

Another strange thing is that it seems like getType() is working fine if used outside of the connectivityChangedEvent callback.

Example code

function networkStateChanged(networkState: RX.Types.DeviceNetworkType) {
  console.log(`network state changed: ${networkState}`;
}

RX.Network.getType() .then(networkStateChanged); // This always resolves

RX.Network.connectivityChangedEvent.subscribe(isConnected => {
  if (isConnected) {
    RX.Network.getType() .then(networkStateChanged); // never resolves
  }
});

I am not able to reproduce this behavior on Android. This API reliably works as expected on Android. I have not tested using the underlying RN API directly.

@erictraut
Copy link
Contributor

The RX.Network implementation is very simple — just a lightweight wrapper on top of RN.NetInfo. With the behaviors you describe above, it sounds like a bug in RN.iOS. I recommend that you open a bug report in the RN project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants