I'm working on a Vue.js application where I have to deal with deeply nested data structures (trees and forests).
After reading about using simple data structures, pure functions and reducing (non-local) mutation, I belief that embracing those ideas would increase the maintainability and simplicity of my code.
While implementing a tree manipulation module using nothing but pure functions, I learned two things:
cloneDeep()
invocationsYesterday, I stumbled upon Immutable.js, which looks great to me. After a bit of playing around with it, I feel like it makes my pure functions much easier to reason about.
My Vue.js components would use fromJS(treeNode)
and treeNode.toJS()
when interacting with the manipulation module.
My question: is it technically possible to Vue.js and Immutable.js together? What are things to keep in mind? Are people using this combination in production? I found this post, which seems to suggest the opposite. That's all I could find.
What are the caveats or practical downsides? Would you suggest to use Immutable.js or to keep deeply cloning regular objects?
edit: updated my question in response to the votes, to make it (less) opinion-based
VueJS is designed to be mutable so that they can be tracked by Vue, while immer tries to achieve the opposite. It doesn't add any value.
Update on 12 Aug 2021 Happily, the creator of Immutable JS resumed to maintaining his lib, and commits are regular now.
Immutable. js is a library that supports an immutable data structure. It means that once created data cannot be changed. It makes maintaining immutable data structures easier and more efficient. The tool supports data structure like: List, Map, Set and also structures that are not implemented in .
js is a cross-platform and open-source back-end framework that executes JavaScript code on the server-side. Vue. js is a structural, open-source JavaScript framework that is used for building UIs and single-page applications.
Just reading about this myself, and apparently not: https://forum.vuejs.org/t/immutable-js-with-vue/6366
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With