Skip to content

Commit

Permalink
Keep the payload into request action
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusdacal committed Dec 4, 2017
1 parent e84620d commit d89d2db
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-arc",
"version": "0.4.1",
"version": "0.4.2",
"description": "Abstraction layer to simplify rest api calls in redux",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
6 changes: 5 additions & 1 deletion src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import { getRequestMiddlewares } from './requestMiddlewares';

function execAsyncTask(requestType, asyncTask) {
return store => next => (action) => {
store.dispatch({ type: requestType, meta: action.meta });
store.dispatch({
type: requestType,
meta: action.meta,
payload: action.payload,
});

const done = (err, response) => next(action, err, response);

Expand Down
2 changes: 1 addition & 1 deletion test/middleware.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('createAsyncMiddleware', () => {
const nextMock = jest.fn();
const apiMiddleware = createAsyncMiddleware(asyncTask)(storeApi)(nextMock);

apiMiddleware({ type: 'REGULAR_ACTION', meta: {} });
apiMiddleware({ type: 'REGULAR_ACTION', meta: {}, });
expect(nextMock.mock.calls.length).toBe(1);
});

Expand Down
2 changes: 2 additions & 0 deletions test/middlewareWithRedux.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Testing middleware on redux', () => {
expect(mockReducer.mock.calls[0][1]).toEqual({
type: 'REQUEST_ACTION',
meta: { url: 'test' },
payload: {},
});

expect(mockReducer.mock.calls[1][1]).toEqual({
Expand Down Expand Up @@ -78,6 +79,7 @@ describe('Testing middleware on redux', () => {

expect(mockReducer.mock.calls[0][1]).toEqual({
type: 'REQUEST_ACTION',
payload: {},
meta: {
url: 'test',
middlewares: ['onRequestMiddleware', 'onResponseMiddleware'],
Expand Down

0 comments on commit d89d2db

Please sign in to comment.