Permalink
Browse files

exporting modules properly without needing babel plugins

  • Loading branch information...
rgommezz committed Jun 3, 2017
1 parent 9104d54 commit 291529315a24ab2d43d168280e003ec4df076de6
Showing with 32 additions and 33 deletions.
  1. +1 −1 .babelrc
  2. +6 −11 src/actionCreators.js
  3. +15 −6 src/actionTypes.js
  4. +5 −5 src/index.js
  5. +5 −10 src/reducer.js
View
@@ -1,4 +1,4 @@
{
"presets": ["es2015", "stage-0"],
"presets": ["react-native"],
"plugins": ["transform-flow-strip-types"]
}
View
@@ -1,24 +1,19 @@
/* @flow */
import {
CONNECTION_CHANGE,
FETCH_OFFLINE_MODE,
REMOVE_FROM_ACTION_QUEUE,
DISMISS_ACTIONS_FROM_QUEUE
} from './actionTypes';
import actionTypes from './actionTypes';
import type { FluxAction } from './types';
type EnqueuedAction = FluxAction | Function;
export const connectionChange = (isConnected: boolean): FluxAction => ({
type: CONNECTION_CHANGE,
type: actionTypes.CONNECTION_CHANGE,
payload: isConnected
});
export const fetchOfflineMode = (action: EnqueuedAction): FluxAction => {
if (typeof action === 'object') {
return {
type: FETCH_OFFLINE_MODE,
type: actionTypes.FETCH_OFFLINE_MODE,
payload: {
prevAction: {
type: action.type,
@@ -30,7 +25,7 @@ export const fetchOfflineMode = (action: EnqueuedAction): FluxAction => {
}
// Thunk
return {
type: FETCH_OFFLINE_MODE,
type: actionTypes.FETCH_OFFLINE_MODE,
payload: {
prevThunk: action
},
@@ -39,11 +34,11 @@ export const fetchOfflineMode = (action: EnqueuedAction): FluxAction => {
};
export const removeActionFromQueue = (action: EnqueuedAction): FluxAction => ({
type: REMOVE_FROM_ACTION_QUEUE,
type: actionTypes.REMOVE_FROM_ACTION_QUEUE,
payload: action
});
export const dismissActionsFromQueue = (actionTrigger: string): FluxAction => ({
type: DISMISS_ACTIONS_FROM_QUEUE,
type: actionTypes.DISMISS_ACTIONS_FROM_QUEUE,
payload: actionTrigger
});
View
@@ -1,8 +1,17 @@
/* @flow */
export const CONNECTION_CHANGE = '@@network-connectivity/CONNECTION_CHANGE';
export const FETCH_OFFLINE_MODE = '@@network-connectivity/FETCH_OFFLINE_MODE';
export const REMOVE_FROM_ACTION_QUEUE =
'@@network-connectivity/REMOVE_FROM_ACTION_QUEUE';
export const DISMISS_ACTIONS_FROM_QUEUE =
'@@network-connectivity/DISMISS_ACTIONS_FROM_QUEUE';
type ActionTypes = {|
CONNECTION_CHANGE: '@@network-connectivity/CONNECTION_CHANGE',
FETCH_OFFLINE_MODE: '@@network-connectivity/FETCH_OFFLINE_MODE',
REMOVE_FROM_ACTION_QUEUE: '@@network-connectivity/REMOVE_FROM_ACTION_QUEUE',
DISMISS_ACTIONS_FROM_QUEUE: '@@network-connectivity/DISMISS_ACTIONS_FROM_QUEUE'
|};
const actionTypes: ActionTypes = {
CONNECTION_CHANGE: '@@network-connectivity/CONNECTION_CHANGE',
FETCH_OFFLINE_MODE: '@@network-connectivity/FETCH_OFFLINE_MODE',
REMOVE_FROM_ACTION_QUEUE: '@@network-connectivity/REMOVE_FROM_ACTION_QUEUE',
DISMISS_ACTIONS_FROM_QUEUE: '@@network-connectivity/DISMISS_ACTIONS_FROM_QUEUE'
};
export default actionTypes;
View
@@ -1,5 +1,5 @@
export reducer from './reducer';
export withNetworkConnectivity from './withNetworkConnectivity';
export ConnectivityRenderer from './ConnectivityRenderer';
export createNetworkMiddleware from './createNetworkMiddleware';
export * as actionTypes from './actionTypes';
export { default as reducer } from './reducer';
export { default as withNetworkConnectivity } from './withNetworkConnectivity';
export { default as ConnectivityRenderer } from './ConnectivityRenderer';
export { default as createNetworkMiddleware } from './createNetworkMiddleware';
export { default as offlineActionTypes } from './actionTypes';
View
@@ -1,12 +1,7 @@
/* @flow */
import { get, isEqual, find, without } from 'lodash';
import {
CONNECTION_CHANGE,
FETCH_OFFLINE_MODE,
REMOVE_FROM_ACTION_QUEUE,
DISMISS_ACTIONS_FROM_QUEUE
} from './actionTypes';
import actionTypes from './actionTypes';
import type { FluxAction, NetworkState } from './types';
export const initialState = {
@@ -77,16 +72,16 @@ export default function(
action: FluxAction
) {
switch (action.type) {
case CONNECTION_CHANGE:
case actionTypes.CONNECTION_CHANGE:
return {
...state,
isConnected: action.payload
};
case FETCH_OFFLINE_MODE:
case actionTypes.FETCH_OFFLINE_MODE:
return handleOfflineAction(state, action);
case REMOVE_FROM_ACTION_QUEUE:
case actionTypes.REMOVE_FROM_ACTION_QUEUE:
return handleRemoveActionFromQueue(state, action.payload);
case DISMISS_ACTIONS_FROM_QUEUE:
case actionTypes.DISMISS_ACTIONS_FROM_QUEUE:
return dismissActionsFromQueue(state, action.payload);
default:
return state;

0 comments on commit 2915293

Please sign in to comment.