facebook/immutable-js — pull request #212 by pluma (2014-11-21 22:53:51+00:00)
Title: Allow cursor onChange function to intercept the cursor's new value

This is a small change that makes the cursor's onChange function more useful.

The cursor's `update` method's callback can currently return arbitrary data. This data is always passed to the onChange function, but then the cursor chokes on invalid data when it tries to return a new cursor.

This change adjusts the behaviour of the onChange function so it can optionally return new rootData for the cursor that should be used instead of what the update method's callback returned.

For an example where this change would allow a nicer application structure see [this issue](https://github.com/foss-haas/fynx/issues/6). Allowing cursors to receive arbitrary data that is then transformed into the correct format "upstream" (e.g. simply calling `Immutable.fromJS` on it) can be useful in React.