3 ms·
For a couple of years I've been using Zustand and Immer for state + actions + select/subscribe to update views. I'm curious to try Mutative, it looks like a dro
by lioeters 3y ago
For a couple of years I've been using Zustand and Immer for state + actions + select/subscribe to update views. I'm curious to try Mutative, it looks like a drop-in replacement for Immer (except the main function is called "create" instead of "produce"). I wonder what the secret sauce is to make it so much faster, and if there are any downsides to it.
- Leftium 3y agoThe readme explains how Mutative achieves better performance over Immer: https://github.com/unadlib/mutative#readme https://github.com/unadlib/mutative#readme
- lioeters 3y agoThank you, I think I just needed to read more carefully. Compared to the spread operation ("naive handcrafted reducer"): > [Mutative] focuses on shallow copy optimization, more complete lazy drafts, finalization process optimization, and more. Compared to Immer: > Immer relies on auto-freeze to be enabled, if auto-freeze is disabled, Immer will have a huge performance drop and Mutative will have a huge performance lead, especially with large data structures. Oh, I didn't notice this: Full compliance with JSON Patch specification. Interesting!