refractproject / minim

A library for interacting with Refract elements
MIT License
21 stars 9 forks source link

Immutability #13

Open smizell opened 9 years ago

smizell commented 9 years ago

I am interested in making the getters and setters be immutable. This means that when you set a value, the old value is not changed, but rather a new object is returned. This requires some fancy work to pass changes up and down the hierarchy and to share the tree, which shouldn't be too hard.

When it's done, it could be a really cool library for use with React, as a component could listen in on only one part of the tree using callbacks.

fosrias commented 9 years ago

What about performance with that overhead of duping the object and then changing?

smizell commented 9 years ago

No need to dupe the object I don't think. Since we are not using a data structure here and simply JS objects for each value, we can share the whole tree and only change the one value while saving the previous.

On Saturday, February 14, 2015, Mark W. Foster notifications@github.com wrote:

What about performance with that overhead of duping the object and then changing?

— Reply to this email directly or view it on GitHub https://github.com/smizell/minim/issues/13#issuecomment-74403454.

smizell commented 9 years ago

I'm going to table this idea for now.

smizell commented 9 years ago

Well, I'm going to leave this open, as this may be something for future releases. I found this and it may actually be a cool fit for the internals of this if immutability is desired.

https://github.com/facebook/immutable-js