Skip to content

Conversation

@JasonKid
Copy link
Contributor

Support that when reducer in actionMap is undefined or null, set it to identity function

@yangmillstheory
Copy link
Contributor

Thanks @JasonKid, I'll get to this this weekend.

@yangmillstheory yangmillstheory self-requested a review July 1, 2017 16:53
@yangmillstheory
Copy link
Contributor

yangmillstheory commented Jul 1, 2017

Made some updates. This adds a new feature, so I'll release this as 2.1.0.

@yangmillstheory yangmillstheory merged commit b9101a3 into redux-utilities:master Jul 1, 2017
@yangmillstheory
Copy link
Contributor

2.1.0 is out:

福 ~/c/p/redux-actions (a0a9f00)|master✓
± : npm publish
npm WARN prepublish-on-install As of npm@5, `prepublish` scripts will run only for`npm publish`.
npm WARN prepublish-on-install (In npm@4 and previous versions, it also runs for `npm install`.)
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.

> redux-actions@2.1.0 prepublish /Users/VictorAlvarez/code/private/redux-actions
> npm run lint && npm run test && npm run build


> redux-actions@2.1.0 lint /Users/VictorAlvarez/code/private/redux-actions
> esw build src webpack.config --color

✓ Clean (10:21:26 AM)

> redux-actions@2.1.0 test /Users/VictorAlvarez/code/private/redux-actions
> mocha --compilers js:babel-register src/**/*-test.js



  camelCase
    ✓ should camel case a conventional action type
    ✓ should include forward slashes in words
    ✓ should do nothing to an already camel-cased action type

  combineActions
    ✓ should throw an error if any action is not a function or string
    ✓ should accept action creators and action type strings
    ✓ should return a stringifiable object

  createAction()
    resulting action creator
      ✓ returns a valid FSA
      ✓ uses return value as payload
      ✓ should throw an error if payloadCreator is not a function, undefined, null
      ✓ uses identity function if payloadCreator is undefined
      ✓ uses identity function if payloadCreator is null
      ✓ accepts a second parameter for adding meta to object
      ✓ sets error to true if payload is an Error object
      ✓ sets error to true if payload is an Error object and meta is provided
      ✓ sets payload only when defined
      ✓ bypasses payloadCreator if payload is an Error object
      ✓ set error to true if payloadCreator return an Error object

  createActions
    ✓ should throw an error when given arguments that contain a non-string
    ✓ should throw an error when given bad payload creators
    ✓ should throw an error when given a bad payload or meta creator in array form
    ✓ should throw an error when no meta creator is given in array form
    ✓ should return a map of camel-cased action types to action creators
    ✓ should honor special delimiters in action types
    ✓ should use the identity if the payload creator is undefined in array form
    ✓ should use the identity and meta creators in array form
    ✓ should use identity payload creators for trailing string action types
    ✓ should create actions from an action map and action types
    ✓ should create actions from a namespaced action map
    ✓ should create namespaced actions with payload creators in array form
    ✓ should create namespaced actions with a chosen namespace string

  handleAction()
    ✓ should throw an error if the reducer is the wrong type
    ✓ uses the identity if the specified reducer is undefined
    single handler form
      ✓ should throw an error if defaultState is not specified
      resulting reducer
        ✓ returns previous state if type does not match
        ✓ returns default state if type does not match
        ✓ accepts single function as handler
        ✓ accepts action function as action type
        ✓ accepts a default state used when the previous state is undefined
        ✓ should work with createActions action creators
        ✓ should not throw and return state when action is non-FSA
    map of handlers form
      ✓ should throw an error if defaultState is not specified
      resulting reducer
        ✓ returns previous state if type does not match
        ✓ uses `next()` if action does not represent an error
        ✓ uses `throw()` if action represents an error
        ✓ returns previous state if matching handler is not function
    with combined actions
      ✓ should handle combined actions in reducer form
      ✓ should handle combined actions in next/throw form
      ✓ should handle combined error actions
      ✓ should return previous state if action is not one of the combined actions
      ✓ should use the default state if the initial state is undefined
      ✓ should handle combined actions with symbols

  handleActions
    ✓ should throw an error when defaultState is not defined
    ✓ should throw an error when defaultState is not defined for combinedActions
    ✓ create a single handler from a map of multiple action handlers
    ✓ works with symbol action types
    ✓ accepts a default state used when previous state is undefined
    ✓ accepts action function as action type
    ✓ should accept combined actions as action types in single reducer form
    ✓ should accept combined actions as action types in the next/throw form
    ✓ should work with createActions action creators
    ✓ should work with namespaced actions
    ✓ should return default state with empty handlers and undefined previous state
    ✓ should return previous defined state with empty handlers
    ✓ should throw an error if handlers object has the wrong type

  namespacing actions
    flattenActionMap
      ✓ should flatten an action map with the default namespacer
      ✓ should do nothing to an already flattened map
      ✓ should be case-sensitive
      ✓ should use a custom namespace string
    unflattenActionCreators
      ✓ should unflatten a flattened action map and camel-case keys
      ✓ should unflatten a flattened action map with custom namespace


  70 passing (389ms)


> redux-actions@2.1.0 build /Users/VictorAlvarez/code/private/redux-actions
> npm run clean && npm run build:es && npm run build:commonjs && npm run build:umd&& npm run build:umd:min


> redux-actions@2.1.0 clean /Users/VictorAlvarez/code/private/redux-actions
> rimraf lib es


> redux-actions@2.1.0 build:es /Users/VictorAlvarez/code/private/redux-actions
> cross-env BABEL_ENV=es babel src --out-dir es --ignore *-test.js

src/arrayToObject.js -> es/arrayToObject.js
src/camelCase.js -> es/camelCase.js
src/combineActions.js -> es/combineActions.js
src/createAction.js -> es/createAction.js
src/createActions.js -> es/createActions.js
src/handleAction.js -> es/handleAction.js
src/handleActions.js -> es/handleActions.js
src/index.js -> es/index.js
src/namespaceActions.js -> es/namespaceActions.js
src/ownKeys.js -> es/ownKeys.js

> redux-actions@2.1.0 build:commonjs /Users/VictorAlvarez/code/private/redux-actions
> babel src --out-dir lib --ignore *-test.js

src/arrayToObject.js -> lib/arrayToObject.js
src/camelCase.js -> lib/camelCase.js
src/combineActions.js -> lib/combineActions.js
src/createAction.js -> lib/createAction.js
src/createActions.js -> lib/createActions.js
src/handleAction.js -> lib/handleAction.js
src/handleActions.js -> lib/handleActions.js
src/index.js -> lib/index.js
src/namespaceActions.js -> lib/namespaceActions.js
src/ownKeys.js -> lib/ownKeys.js

> redux-actions@2.1.0 build:umd /Users/VictorAlvarez/code/private/redux-actions
> cross-env NODE_ENV=development webpack

Hash: 04266d5a9762cd2bf2ec
Version: webpack 1.13.1
Time: 1164ms
           Asset     Size  Chunks             Chunk Names
redux-actions.js  83.9 kB       0  [emitted]  main
    + 83 hidden modules

> redux-actions@2.1.0 build:umd:min /Users/VictorAlvarez/code/private/redux-actions
> cross-env NODE_ENV=production webpack

Hash: 65adbb441ed26f84010d
Version: webpack 1.13.1
Time: 1635ms
               Asset     Size  Chunks             Chunk Names
redux-actions.min.js  21.3 kB       0  [emitted]  main
    + 83 hidden modules
+ redux-actions@2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants