Comments (13)
I have just run into this problem when trying to create a list of file uploads which needs to store the original File objects because without them you won't be able to send the files.
from seamless-immutable.
In any case this was one of the primary reasons I went back to Immutable.js. I was tempted to fork this project, but didn't have time.
from seamless-immutable.
I found another solution. Regular objects + RamdaJS
My favourite method is "evolve" because it solves so many problems and it's all immutable
from seamless-immutable.
Unfortunate that it breaks React's common usage pattern. But for a immutable lib, it makes sense to immute all methods which creates new objects.
However, it would be awesome if there's an api to avoid creating immutables when it is not required..
from seamless-immutable.
@sudhakar With over 9000 stars on Immutable.js, which allows mutable objects to be stored inside immutable objects, it's clear plenty of people think the most useful behavior is not to automatically immutablize everything.
"Makes sense" is vague; a more concrete design goal is to make a library convenient for common use cases. I'd argue that map
ping to mutable objects is a fairly common use case, as in my above example, and it's one that Immutable.js is a lot more convenient for.
from seamless-immutable.
@jedwards1211 I dont have a strong opinion on this. I am all up for having mutable methods being part of the API. Changing the map
or filter
methods to return mutable objects is a big call. @rtfeldman might be the right person to decide on that.
BTW, there's already a thread open to have mutuable api. See more discussion on #56 & chime in with your proposal so that others in community can throw in their thoughts.
Note that I am not a maintainer/owner of this repo. I am just a user like who wants to use it with React ;)
from seamless-immutable.
I know you're not the owner :)
What I'm talking about map
and filter
doing is a bit more subtle. The way they work in Immutable.js is to return an immutable array containing the exact objects returned by your mapper function: if it returns mutable objects, you get an immutable array with mutable objects as elements. Oftentimes when your source object is immutable all the way down, your mapper function will just return the result of some Immutable.js method calls on the elements, which return other immutables, meaning map
will return a fully immutable array anyway. But if your mapper function returns something completely different, like React elements as in my example, you'll get an immutable array containing (mutable) React elements.
from seamless-immutable.
In any case, you might have noticed that Feldman hasn't commented on these threads at all...I think he's not even interested. I'd be happy if someone made a competing fork
from seamless-immutable.
@pbc using Ramda is kind of nifty. What I really want to know is how well Immutable.js performs compared to copying JS objects. Supposedly it can share most of the unchanged data between objects saving time and memory.
from seamless-immutable.
I stumbled upon the same issue. One way to get around it, would be using lodash instead of the native map function...
_.map(items, (item, i) => <div key={i}>{item}</div>);
...or convert it to a mutable array before performing the map
items.asMutable().map((item, i) => <div key={i}>{item}</div>);
from seamless-immutable.
Yes...I'm trying to argue that it shouldn't be necessary to do that
from seamless-immutable.
Sorry I took so long to respond to this.
I totally understand the idea here, but to me the invariant that calls to Immutable() consistently result in values that are immutable is more important than this convenience of not having to call .asMutable() or use something like _.map. I think the value of API consistency wins here.
Thanks for raising this point, and for the discussion, but I'm going to close this just to be totally clear on where I stand on this: calls to Immutable() should always return values that are immutable.
from seamless-immutable.
Okay, well, I will stick with ImmuableJS then.
from seamless-immutable.
Related Issues (20)
- Make `without` support removing item from an array HOT 4
- how to use splice like array HOT 1
- Internet Explorer tests are failing HOT 4
- Issue regarding null values HOT 5
- Why are IE tests failing? HOT 3
- How to apply splice with seamless-immutable? HOT 1
- Merge does not work with class instances
- __immutable_invariants_hold is enumerable on Edge HOT 1
- Garbage collector features? HOT 1
- Performance characteristics
- Any difference with deepCopy? HOT 1
- [types] Mixin not applied to nested objects HOT 1
- flatMap not working HOT 2
- Add documentation for merge mode
- Files not being replaced on a deep merge
- Fails on IE 11 HOT 1
- TypeError: Object(...) is not a function HOT 1
- Lodash Vulnerability Problem
- Is the project still maintained? HOT 2
- immutable object causes rapid memory growth HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seamless-immutable.