Skip to content

Commit

Permalink
[enhance] if object is contained in extraPropNames, merge and provide…
Browse files Browse the repository at this point in the history
… them to action object
  • Loading branch information
drunkhacker committed Nov 14, 2017
1 parent fa8bca6 commit 6e0a3d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/createActions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createTypes from './createTypes'
import { is, isNil, isEmpty, join, keys, map, mapObjIndexed, merge, pick, pipe, replace, toUpper, zipObj } from 'ramda'
import { is, isNil, isEmpty, join, keys, map, mapObjIndexed, merge, pick, pipe, replace, toUpper, zipObj, filter, mergeAll } from 'ramda'

const defaultOptions = {
prefix: ''
Expand Down Expand Up @@ -41,8 +41,11 @@ const createActionCreator = (name, extraPropNames, options) => {
// "properties" is defined as an array of prop names
if (is(Array, extraPropNames)) {
return (...values) => {
const extraProps = zipObj(extraPropNames, values)
return { type, ...extraProps }
const stringKeys = filter(n => is(String, n), extraPropNames);
const objs = filter(n => is(Object, n), extraPropNames);
const providedProps = mergeAll(objs);
const extraProps = zipObj(stringKeys, values);
return { type, ...providedProps, ...extraProps };
}
}

Expand Down

0 comments on commit 6e0a3d3

Please sign in to comment.