Skip to content
This repository was archived by the owner on Nov 23, 2020. It is now read-only.

Commit 841a61a

Browse files
author
Vince Speelman
committed
fix(creators): don't invoke promises. duh
I mistakenly evaluated promises in place upon generation. Instead, I'm now naievely assuming that if you return a function, you might need async actions. If you don't, no problem.
1 parent 2de67ef commit 841a61a

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { createActions as act } from 'redux-actions';
22

33
const STATES = ['REQUESTED', 'RECEIVED', 'REJECTED'];
4-
const isPromise = value => {
5-
let test = value;
6-
if (typeof value === 'function') {
7-
test = value();
8-
}
9-
return Promise.resolve(test) === test;
10-
};
4+
const isPromise = value => Promise.resolve(value) === value;
115

126
const createActions = (
137
{ states = STATES, prefix = '' } = {
@@ -20,8 +14,7 @@ const createActions = (
2014
(acc, [k, v]) => ({
2115
...acc,
2216
[k]: isPromise(v) ? () => v : v,
23-
...(v &&
24-
isPromise(v) &&
17+
...(((v && isPromise(v)) || typeof v === 'function') &&
2518
states.reduce(
2619
(acc, curr) => ({
2720
...acc,

0 commit comments

Comments
 (0)