Skip to content

Commit ad7f22c

Browse files
Merge branch 'master' into hygiene/check-reducers
2 parents 51e73aa + 4b6a980 commit ad7f22c

File tree

7 files changed

+29
-7
lines changed

7 files changed

+29
-7
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
[*]
3+
indent_style = space
4+
indent_size = 2
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
[*.md]
10+
trim_trailing_whitespace = false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ coverage
33
*.log
44
lib
55
dist
6+
.idea

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: node_js
22
node_js:
33
- "6"
4-
- "5"
54
- "4"
65
script:
76
- npm run lint

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# redux-actions
22

33
[![build status](https://img.shields.io/travis/acdlite/redux-actions/master.svg?style=flat-square)](https://travis-ci.org/acdlite/redux-actions)
4-
[![npm version](https://img.shields.io/npm/v/redux-actions.svg?style=flat-square)](https://www.npmjs.com/package/redux-actions)
4+
5+
[![NPM](https://nodei.co/npm/redux-actions.png?downloads=true)](https://nodei.co/npm/redux-actions/)
56

67
[Flux Standard Action](https://github.com/acdlite/flux-standard-action) utilities for Redux.
78

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-actions",
3-
"version": "0.12.0",
3+
"version": "0.13.0",
44
"description": "Flux Standard Action utlities for Redux",
55
"main": "lib/index.js",
66
"scripts": {

src/__tests__/createAction-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,16 @@ describe('createAction()', () => {
130130
meta: { foo: 'bar' }
131131
});
132132
});
133+
134+
it('set error to true if payloadCreator return an Error object', () => {
135+
const errObj = new TypeError('this is an error');
136+
const actionCreator = createAction(type, () => errObj);
137+
const errAction = actionCreator('invalid arguments');
138+
expect(errAction).to.deep.equal({
139+
type,
140+
payload: errObj,
141+
error: true
142+
});
143+
});
133144
});
134145
});

src/createAction.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function createAction(type, payloadCreator, metaCreator) {
55
? payloadCreator
66
: identity;
77

8-
const actionHandler = (...args) => {
8+
const actionCreator = (...args) => {
99
const hasError = args[0] instanceof Error;
1010

1111
const action = {
@@ -17,7 +17,7 @@ export default function createAction(type, payloadCreator, metaCreator) {
1717
action.payload = payload;
1818
}
1919

20-
if (hasError) {
20+
if (hasError || payload instanceof Error) {
2121
// Handle FSA errors where the payload is an Error object. Set error.
2222
action.error = true;
2323
}
@@ -29,7 +29,7 @@ export default function createAction(type, payloadCreator, metaCreator) {
2929
return action;
3030
};
3131

32-
actionHandler.toString = () => type.toString();
32+
actionCreator.toString = () => type.toString();
3333

34-
return actionHandler;
34+
return actionCreator;
3535
}

0 commit comments

Comments
 (0)