Closed darthrellimnad closed 7 years ago
Also some comments about what you said:
Root state can not be ignored this way. Using empty string in ignore array won't match any branches of state. If this is the case, then probably you don't even need this middleware, right? So I'd say it's not a problem.
array indices can be ignored, but doesn't match familiar syntax e.g. 'stuff.0' path string would ignore mutation detection for elt at state.stuff[0]
This is fine for me, though it's a weird use case to try to ignore a specific index in an array.
These changes also alter the function signature of the exported trackForMutations method, which could be a problem if people are using this method directly, outside of normal usage via immutableStateInvariantMiddleware, so this can be considered a breaking change in that respect.
trackForMutations
is not exposed in the public API, so we're free to change it. Anyway, I proposed a change in the middleware signature so that will require a major version bump.
thanks for the feedback! :) I'll get started on those changes soon (have to finish up some other work related things first).
re: ignoring array indices - I agree, uncommon use case and I don't think I'd ever have use for it. It just sort of ended up being supported with the implementation I came up with, so figured I'd call it out :)
Code review comments have been addressed, so let me know if anything else is desired or necessary :). I can update the README if you'd like to document the public api options, although not sure if you have a preferred format or feel this is necessary at this time.
Edit: also added a test for the isImmutable
option, after realizing i hadn't run test:coverage
script. that seemed to be the only test case keeping branch coverage under 100%
I can update the README if you'd like to document the public api options, although not sure if you have a preferred format or feel this is necessary at this time.
Actually yes! I was going to ask you but forgot. Also, I will have time to review this on Monday probably, so if you can include the readme change before I review that'd be great (no problem if not!)
OK, took a stab at some public API documentation :) however, when i pushed the change, looks like the test coverage dropped and is now failing a check. not sure how this change would have affected that, but it may be something I'm missing or not understanding in the CI environment or with coveralls specifically?
Edit:
Looked at it a bit more, and may actually be related to a recent version update of coveralls
to v2.12.0. Just a guess at the moment, but release notes mention updates for branch coverage support: https://github.com/nickmerwin/node-coveralls/releases
A recent issue also seems similar to what I'm seeing, so maybe it'll be fixed in a patch release or more info will be provided: https://github.com/nickmerwin/node-coveralls/issues/158
This update seems to have been made shortly before my last commit was pushed to origin and failed builds seem to correspond to travis job logs that report installing the updated (v2.12.0) version of coveralls.
Cool! Thanks for the work on this PR! Will merge it and soon I'll create a new release. Will tweak the readme a bit but I'll do that on my own so that I don't take more time from you.
Again, thanks a lot! 🎉
np 👍 thanks again for sharing!
amazing job thanks guys! 🍾 @darthrellimnad @leoasis
I've been using
redux-immutable-state-invariant
for a while now and it's been really helpful :)I ran across the following issue while looking into a way to deal with some performance problems when using this in development with a redux store that houses very large datasets: https://github.com/leoasis/redux-immutable-state-invariant/issues/20
Figured i'd take a stab at it, but let me know if I'm just making a mess :)
My use case doesn't actually use Immutable.js for any branches of state, but we store lots data that we receive from an API as normalized entities under specific paths (using
normalizr
: https://github.com/paularmstrong/normalizr).When we need to test locally with large datasets, we found
redux-immutable-state-invariant
really made our app chug, so we would disable the mutation checking entirely. I desired a way to turn "off" mutation detection via configuration so that we can keep detection enabled for most branches, while ignoring the problematic ones as needed.These changes add an
options
argument toimmutableStateInvariantMiddleware
. The only supported option right now isignore
, which can be an array of dot-separated "path" strings:Some notes on implementation:
ignore
array won't match any branches of state.state.stuff[0]
These changes also alter the function signature of the exported
trackForMutations
method, which could be a problem if people are using this method directly, outside of normal usage viaimmutableStateInvariantMiddleware
, so this can be considered a breaking change in that respect. Usage ofimmutableStateInvariantMiddleware
should be backwards compatible.