Inline util from redux-actions to reduce bundle size

pull/3638/head
Thibaud Colas 2017-06-07 17:21:00 +03:00
rodzic e64903659e
commit 6cfd139cc2
4 zmienionych plików z 27 dodań i 3 usunięć

Wyświetl plik

@ -31,6 +31,7 @@ Array [
exports[`actions toggleExplorer close 1`] = `
Array [
Object {
"payload": undefined,
"type": "CLOSE_EXPLORER",
},
]

Wyświetl plik

@ -1,6 +1,5 @@
import { createAction } from 'redux-actions';
import * as admin from '../../api/admin';
import { createAction } from '../../utils/actions';
import { MAX_EXPLORER_PAGES } from '../../config/wagtailConfig';
const getPageStart = createAction('GET_PAGE_START');

Wyświetl plik

@ -0,0 +1,25 @@
const identity = func => func;
// Stolen from the following project (had a 18kb footprint at the time).
// https://github.com/acdlite/redux-actions/blob/79c68635fb1524c1b1cf8e2398d4b099b53ca8de/src/createAction.js
export function createAction(type, actionCreator, metaCreator) {
const finalActionCreator = typeof actionCreator === 'function' ? actionCreator : identity;
return (...args) => {
const action = {
type,
payload: finalActionCreator(...args),
};
if (action.payload instanceof Error) {
// Handle FSA errors where the payload is an Error object. Set error.
action.error = true;
}
if (typeof metaCreator === 'function') {
action.meta = metaCreator(...args);
}
return action;
};
}

Wyświetl plik

@ -64,7 +64,6 @@
"react-redux": "^5.0.5",
"react-transition-group": "^1.1.3",
"redux": "^3.6.0",
"redux-actions": "^2.0.3",
"redux-thunk": "^2.2.0",
"whatwg-fetch": "^2.0.2"
},