leoasis / redux-immutable-state-invariant

Redux middleware that detects mutations between and outside redux dispatches. For development use only.
MIT License
937 stars 37 forks source link

Why not just freeze? #23

Closed testerez closed 7 years ago

testerez commented 7 years ago

I might be missing something but wouldn't it be enough to deep freeze the state like redux-freeze does?

leoasis commented 7 years ago

To be honest, I haven't used Object.freeze very much. But it looks like it does the job as well. I've seen some caveats where Object.freeze could silently fail, but those are not the case if you use 'use strict'; in a modern browser. What I think is good of a custom approach, like this one, is that we have more freedom to track the path where the exception came from, and log a more useful error to the user in order to track where it came from.

Anyway, if we could achieve something similar with Object.freeze, that'd be great, either applying that in this library or in the one you mentioned.

testerez commented 7 years ago

Thanks for your reply. I'll use redux-freeze until I found any limitation...

leoasis commented 7 years ago

Cool, thanks for commenting!