inaction
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -12,7 +12,8 @@ 'use strict'; | ||
// Helper for redux that makes action creators. | ||
// Helper for redux that makes new action creators. | ||
// | ||
// Takes an optional creator that can be used to dispatch subsequent actions. | ||
// The helper takes an optional action creator factory that can be used to | ||
// dispatch subsequent actions. | ||
// | ||
var action = function action(type, creator) { | ||
var action = function action(type, factory) { | ||
return function (payload) { | ||
@@ -33,3 +34,3 @@ return function () { | ||
if (!creator) { | ||
if (!factory) { | ||
_context.next = 7; | ||
@@ -40,3 +41,3 @@ break; | ||
_context.next = 7; | ||
return creator()(action, dispatch, getState); | ||
return factory()(action, dispatch, getState); | ||
@@ -43,0 +44,0 @@ case 7: |
@@ -8,7 +8,8 @@ import { bindActionCreators } from 'redux'; | ||
// Helper for redux that makes action creators. | ||
// Helper for redux that makes new action creators. | ||
// | ||
// Takes an optional creator that can be used to dispatch subsequent actions. | ||
// The helper takes an optional action creator factory that can be used to | ||
// dispatch subsequent actions. | ||
// | ||
var action = function action(type, creator) { | ||
var action = function action(type, factory) { | ||
return function (payload) { | ||
@@ -29,3 +30,3 @@ return function () { | ||
if (!creator) { | ||
if (!factory) { | ||
_context.next = 7; | ||
@@ -36,3 +37,3 @@ break; | ||
_context.next = 7; | ||
return creator()(action, dispatch, getState); | ||
return factory()(action, dispatch, getState); | ||
@@ -39,0 +40,0 @@ case 7: |
@@ -11,7 +11,8 @@ (function (global, factory) { | ||
// Helper for redux that makes action creators. | ||
// Helper for redux that makes new action creators. | ||
// | ||
// Takes an optional creator that can be used to dispatch subsequent actions. | ||
// The helper takes an optional action creator factory that can be used to | ||
// dispatch subsequent actions. | ||
// | ||
var action = function action(type, creator) { | ||
var action = function action(type, factory) { | ||
return function (payload) { | ||
@@ -32,3 +33,3 @@ return function () { | ||
if (!creator) { | ||
if (!factory) { | ||
_context.next = 7; | ||
@@ -39,3 +40,3 @@ break; | ||
_context.next = 7; | ||
return creator()(action, dispatch, getState); | ||
return factory()(action, dispatch, getState); | ||
@@ -42,0 +43,0 @@ case 7: |
{ | ||
"name": "inaction", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Assorted helpers for Redux.", | ||
@@ -17,3 +17,3 @@ "repository": "github:olav/rection", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-env": "^1.7.0", | ||
"eslint": "^4.19.1", | ||
@@ -23,3 +23,3 @@ "jest": "^22.4.3", | ||
"prettier": "^1.12.1", | ||
"rollup": "^0.58.2", | ||
"rollup": "^0.59.1", | ||
"rollup-plugin-babel": "^3.0.4", | ||
@@ -26,0 +26,0 @@ "rollup-plugin-commonjs": "^9.1.3", |
@@ -1,6 +0,7 @@ | ||
// Helper for redux that makes action creators. | ||
// Helper for redux that makes new action creators. | ||
// | ||
// Takes an optional creator that can be used to dispatch subsequent actions. | ||
// The helper takes an optional action creator factory that can be used to | ||
// dispatch subsequent actions. | ||
// | ||
export const action = (type, creator) => payload => async ( | ||
export const action = (type, factory) => payload => async ( | ||
dispatch, | ||
@@ -12,4 +13,4 @@ getState | ||
if (creator) { | ||
await creator()(action, dispatch, getState); | ||
if (factory) { | ||
await factory()(action, dispatch, getState); | ||
} | ||
@@ -16,0 +17,0 @@ |
@@ -15,9 +15,9 @@ import { action } from "./action"; | ||
test("action with subsequent action creator", async () => { | ||
test("action with factory", async () => { | ||
expect.assertions(2); | ||
const creator0 = () => a => expect(a).toEqual(testAction); | ||
const creator1 = action(testAction.type, creator0)(testAction.payload); | ||
const factory = () => a => expect(a).toEqual(testAction); | ||
const creator = action(testAction.type, factory)(testAction.payload); | ||
expect(await creator1(a => a)).toEqual(testAction); | ||
expect(await creator(a => a)).toEqual(testAction); | ||
}); |
15368
365