Skip to content

Commit

Permalink
Prettier fixes + minor version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommezz committed Oct 3, 2018
1 parent b0281e0 commit 011459c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-offline",
"version": "3.12.0",
"version": "3.13.0",
"description": "Handy toolbelt to deal with offline mode in React Native applications. Cross-platform, provides a smooth redux integration.",
"main": "./src/index.js",
"author": "Raul Gomez Acuña <[email protected]> (https://github.com/rgommezz)",
Expand All @@ -12,7 +12,7 @@
"flow": "flow",
"format": "eslint --fix js/**/",
"prettier": "prettier --single-quote --trailing-comma all --write \"src/**/*.js\"",
"jest:coverage": "node --harmony_proxies node_modules/.bin/jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"jest:coverage": "node --harmony node_modules/.bin/jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"precommit": "yarn run lint"
},
"repository": {
Expand Down
14 changes: 6 additions & 8 deletions src/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,12 @@ function* handleConnectivityChange(
* @param withExtraHeadRequest
* @param checkConnectionInterval
*/
export default function* networkEventsListenerSaga(
{
timeout = 3000,
pingServerUrl = 'https://www.google.com/',
withExtraHeadRequest = true,
checkConnectionInterval = 0,
}: Arguments = {},
): Generator<*, *, *> {
export default function* networkEventsListenerSaga({
timeout = 3000,
pingServerUrl = 'https://www.google.com/',
withExtraHeadRequest = true,
checkConnectionInterval = 0,
}: Arguments = {}): Generator<*, *, *> {
yield fork(netInfoChangeSaga, timeout, pingServerUrl, withExtraHeadRequest);
if (checkConnectionInterval) {
yield fork(
Expand Down
38 changes: 18 additions & 20 deletions src/withNetworkConnectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ type State = {
isConnected: boolean,
};

const withNetworkConnectivity = (
{
withRedux = false,
timeout = 3000,
pingServerUrl = 'http://www.google.com/',
withExtraHeadRequest = true,
checkConnectionInterval = 0,
checkIntervalOfflineOnly = false,
checkInBackground = false,
httpMethod = 'HEAD',
}: Arguments = {},
) => (WrappedComponent: ReactClass<*>) => {
const withNetworkConnectivity = ({
withRedux = false,
timeout = 3000,
pingServerUrl = 'http://www.google.com/',
withExtraHeadRequest = true,
checkConnectionInterval = 0,
checkIntervalOfflineOnly = false,
checkInBackground = false,
httpMethod = 'HEAD',
}: Arguments = {}) => (WrappedComponent: ReactClass<*>) => {
if (typeof withRedux !== 'boolean') {
throw new Error('you should pass a boolean as withRedux parameter');
}
Expand All @@ -51,7 +49,9 @@ const withNetworkConnectivity = (
}

class EnhancedComponent extends PureComponent<void, void, State> {
static displayName = `withNetworkConnectivity(${WrappedComponent.displayName})`;
static displayName = `withNetworkConnectivity(${
WrappedComponent.displayName
})`;

static contextTypes = {
store: PropTypes.shape({
Expand Down Expand Up @@ -112,13 +112,11 @@ const withNetworkConnectivity = (
if (checkInBackground === false && AppState.currentState !== 'active') {
return; // <-- Return early as we dont care about connectivity if apps' not in foreground.
}
checkInternetAccess(
timeout,
pingServerUrl,
httpMethod,
).then((hasInternetAccess: boolean) => {
this.handleConnectivityChange(hasInternetAccess);
});
checkInternetAccess(timeout, pingServerUrl, httpMethod).then(
(hasInternetAccess: boolean) => {
this.handleConnectivityChange(hasInternetAccess);
},
);
};

handleConnectivityChange = (isConnected: boolean) => {
Expand Down

0 comments on commit 011459c

Please sign in to comment.