Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Question: Should I use immutable data structures #1422
I'm considering doing something to prevent bad state mutations. The first thing that I though about was immutable but then I started to think about the potential performance implications.
Some immutable checks will decrease performance because they are adding some run-time overhead. At the same time using immutable could improve performance when used in places like
So my main question are:
I was also trying to find out how to integrate immutable.js with Redux and I found two libraries:
Both libraries force you to use their custom implementation of
I have seem examples that use Redux + immutable.js without
Finally, you don't need any library to use Immutable with Redux. They just give you Immutable-first combineReducers. You can use it or you can write your own. Check their source code and you will see there is nothing fancy going on there. I'm not aware of any problems caused by them so I don't know what you are referring to.
@gaearon thanks for answering!
I feel comfortable about using Immutable.js but I don't feel like I need it at all times. I work with some people that is just getting started with Redux and sometimes the new joiners perform some bad mutations. To prevent this I was considering using immutablejs. The problem is that once they get familiar with Redux we probably won't need it and it will affect performance.
That's why I was wondering if something like
Immutable still leaves plenty of pitfalls for beginners: they can put stuff as instance fields on immutable object, they can forget to
What will affect performance? If anything, Immutable should give you a better performance than plain objects. This is the main reason people like to use it.
No better way than to try and tell us.