Skip to content

Include old values in 'replace' ops. #12

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

Closed
wants to merge 2 commits into from

Conversation

ds300
Copy link

@ds300 ds300 commented Oct 10, 2016

Hi,

First of all, thanks for the great work on this lib 👌 . Not sure if you have any interest in this PR, but it satisfies my use case and I figure it can't hurt to offer.

My use case is as follows: I'm using immutable-js-diff to find out what's changed in a app state tree, and then notify registered listeners if anything pertinent to their interests has changed. Quite a few of the listeners want to know the previous value of the thing that changed, and enabling that manually was becoming a real headache.

The change is simply that e.g.

diff(fromJS({a: 0}), fromJS({a: 1}));
// => List [ Map { "op": "replace", "path": "/a", "value": 1 } ]

becomes

diff(fromJS({a: 0}), fromJS({a: 1}));
// => List [ Map { "op": "replace", "path": "/a", "value": 1, "oldValue": 0 } ]

This could be a breaking change for some people, so no offence will be taken if you laugh me out of the room.

@ds300 ds300 closed this Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant