Skip to content

Commit

Permalink
rename reducer file to createReducer
Browse files Browse the repository at this point in the history
export as default to maintain compatibility.
  • Loading branch information
LiquidSean committed Aug 28, 2019
1 parent 3d90433 commit 95b77d3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ module.exports = {
return require('./components/NetworkConsumer').default;
},
get reducer() {
return require('./redux/reducer').createReducer;
return require('./redux/createReducer').default();
},
get createReducer() {
return require('./redux/createReducer').default;
},
get createNetworkMiddleware() {
return require('./redux/createNetworkMiddleware').default;
Expand Down
7 changes: 4 additions & 3 deletions src/redux/reducer.js → src/redux/createReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ function handleDismissActionsFromQueue(
};
}

export const createReducer = (
comparisonFn: Function = getSimilarActionInQueue,
) => (state: NetworkState = initialState, action: *) => {
export default (comparisonFn: Function = getSimilarActionInQueue) => (
state: NetworkState = initialState,
action: *,
) => {
switch (action.type) {
case actionTypes.CONNECTION_CHANGE:
return {
Expand Down
2 changes: 1 addition & 1 deletion src/redux/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { put, select, call, take, cancelled, fork } from 'redux-saga/effects';
import { eventChannel } from 'redux-saga';
import { AppState, Platform } from 'react-native';
import NetInfo from '@react-native-community/netinfo';
import { networkSelector } from './reducer';
import { networkSelector } from './createReducer';
import checkInternetAccess from '../utils/checkInternetAccess';
import { connectionChange } from './actionCreators';
import type { HTTPMethod } from '../types';
Expand Down
5 changes: 2 additions & 3 deletions test/reducer.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint flowtype/require-parameter-type: 0 */
import { isEqual } from 'lodash';
import {
createReducer,
import createReducer, {
initialState,
networkSelector,
} from '../src/redux/reducer';
} from '../src/redux/createReducer';
import * as actionCreators from '../src/redux/actionCreators';
import getSimilarActionInQueue from '../src/utils/getSimilarActionInQueue';

Expand Down
2 changes: 1 addition & 1 deletion test/sagas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
DEFAULT_PING_SERVER_URL,
DEFAULT_TIMEOUT,
} from '../src/utils/constants';
import { networkSelector } from '../src/redux/reducer';
import { networkSelector } from '../src/redux/createReducer';
import checkInternetAccess from '../src/utils/checkInternetAccess';

const args = {
Expand Down

0 comments on commit 95b77d3

Please sign in to comment.