New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

react-native-offline

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-offline - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

2

package.json
{
"name": "react-native-offline",
"version": "4.0.0",
"version": "4.1.0",
"description": "Handy toolbelt to deal with offline mode in React Native applications. Cross-platform, provides a smooth redux integration.",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -9,3 +9,3 @@ # react-native-offline

## Important (Please read)
**This is the documentation for version 4.0.0. If you are migrating from v3 to v4, check the [release notes](https://github.com/rgommezz/react-native-offline/releases/tag/v4.0.0).**
**This is the documentation for version 4.x.x. If you are migrating from v3 to v4, check the [release notes](https://github.com/rgommezz/react-native-offline/releases/tag/v4.0.0).**

@@ -27,3 +27,3 @@ ## Contents

+ [`networkSaga`](#networksaga)
+ [`createNetworkMiddleware()`](#createnetworkmiddleware)
+ [`createNetworkMiddleware`](#createnetworkmiddleware)
+ [`Offline Queue`](#offline-queue)

@@ -76,3 +76,3 @@ * [Other Utilities](#other-utilities)

```
$ yarn add react-native-offline@4.0.0
$ yarn add react-native-offline
```

@@ -432,4 +432,9 @@

**Note**: It's recommended to always set `shouldPing` to `true` (the default behaviour), in order to prevent inconsistent behaviour on iOS for RN < 0.57.
```js
checkInternetConnection(url?: string = 'https://www.google.com/', pingTimeout?: number = 3000): Promise<boolean>
checkInternetConnection(
url?: string = 'https://www.google.com/',
pingTimeout?: number = 3000,
shouldPing?: boolean = true
): Promise<boolean>
```

@@ -436,0 +441,0 @@

/* @flow */
import { Platform, NetInfo } from 'react-native';
import { NetInfo } from 'react-native';
import checkInternetAccess from './checkInternetAccess';

@@ -9,37 +9,19 @@ import { DEFAULT_PING_SERVER_URL, DEFAULT_TIMEOUT } from './constants';

* Utility that allows to query for internet connectivity on demand
* On iOS, the listener is fired immediately after registration
* On Android, we need to use `isConnected.fetch`, that returns a promise which resolves with a boolean
* @param url
* @param timeout
* @param shouldPing
* @returns {Promise<boolean>}
*/
export default function checkInternetConnection(
export default async function checkInternetConnection(
url: string = DEFAULT_PING_SERVER_URL,
timeout: number = DEFAULT_TIMEOUT,
shouldPing: boolean = true,
): Promise<boolean> {
let connectionChecked: Promise<boolean>;
if (Platform.OS === 'ios') {
connectionChecked = new Promise((resolve: Function) => {
const handleFirstConnectivityChangeIOS = (isConnected: boolean) => {
NetInfo.isConnected.removeEventListener(
'connectionChange',
handleFirstConnectivityChangeIOS,
);
resolve(isConnected);
};
NetInfo.isConnected.addEventListener(
'connectionChange',
handleFirstConnectivityChangeIOS,
);
});
} else {
connectionChecked = NetInfo.isConnected.fetch();
}
return connectionChecked.then((isConnected: boolean) => {
if (isConnected) {
return checkInternetAccess({ timeout, url });
return NetInfo.isConnected.fetch().then(async (isConnected: boolean) => {
if (shouldPing) {
const hasInternetAccess = await checkInternetAccess({ timeout, url });
return hasInternetAccess;
}
return Promise.resolve(false);
return isConnected;
});
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc