Codebrahma / redux-action-watch

Watch/Listen actions dispatched to redux.
https://npmjs.com/package/redux-action-watch
MIT License
11 stars 1 forks source link

Compatibility with redux-immutable-state-invariant #1

Open jasonwong26 opened 6 years ago

jasonwong26 commented 6 years ago

Hello,

First off, great library! I'm using it for a demo project and it has greatly simplified my codebase. In my dev build, I'm also using the leoasis/redux-immutable-state-invariant library to check for state mutations. I've found that your library can throw mutation warnings when adding/removing listeners.

I was able to resolve this in my local copy by modifying the reducer to do a deep copy when cloning the state:

// extracted from reducer.js
var _lodash = require('lodash.foreach');
var _cloneDeep = require('lodash.cloneDeep');

var _lodash2 = _interopRequireDefault(_lodash);
var _cloneDeep2 = _interopRequireDefault(_cloneDeep);

exports.default = function () {
  // other code...

  // clone the state
  // var newState = Object.assign({}, state);
  var newState = _cloneDeep2.default(state);

  // other code...
};

May I create a PR for this change?

thesmilingsloth commented 6 years ago

Yes, you can create a PR!