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

Commit

Permalink
fix(creators): don't invoke promises. duh
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Vince Speelman committed Sep 19, 2018
1 parent 2de67ef commit 841a61a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { createActions as act } from 'redux-actions';

const STATES = ['REQUESTED', 'RECEIVED', 'REJECTED'];
const isPromise = value => {
let test = value;
if (typeof value === 'function') {
test = value();
}
return Promise.resolve(test) === test;
};
const isPromise = value => Promise.resolve(value) === value;

const createActions = (
{ states = STATES, prefix = '' } = {
Expand All @@ -20,8 +14,7 @@ const createActions = (
(acc, [k, v]) => ({
...acc,
[k]: isPromise(v) ? () => v : v,
...(v &&
isPromise(v) &&
...(((v && isPromise(v)) || typeof v === 'function') &&
states.reduce(
(acc, curr) => ({
...acc,
Expand Down

0 comments on commit 841a61a

Please sign in to comment.