-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a lens library to enable deep update of immutable types #84
Comments
It is certainly an interesting idea. I guess the |
Yes that is correct. We have our own internal framework that does this and it works very nicely. Here is one of our test cases.
We can handle immutable lists and dictionaries. Behind the scenes we use reflection to clone and update read only properties but it would work nice with the builder framework you have. |
Due to problems contributing directly to this project I've created a dependent project. https://github.com/bradphelan/ImmutableObjectGraphLens This provides composable lenses over the immutable object graph. Currently it only supports property based selectors, no lists or dictionaries but that can be added. For example the test has the following test data
and a test showing immutable update using lenses and selectors.
More interesting is the ability to attach the immutable object type to a mutable field on an INPC supporting object. We can now create lenses to subproperties of the immutable object and have the mutable property of the root update.
Let me know your ideas on this. |
The technical core of the library is this reflection heavy code that walks a property list recursively calling "With" on each node. Theoretically we could code generate a lens builder that will not require reflection. Any ideas? |
Example I hope explains all. It could be done with reflection on the currently generated immutable update methods.
Writing focus for collections is a bit more tricky but I think can be done.
The text was updated successfully, but these errors were encountered: