Because the replacement code is so small, here it is in its full glory:
& # 39; Strictly use & # 39; module.exports = (object, onChange) => ;
onChange function returns a proxy that you can use to modify an object.
at Change the object you want to spy on and a function for changing handlers:
let j = ; // Save to server when saving let changeable = onChange (j, () => save (j));
Then use that proxy to change properties and receive notifications of changes:
// Make a change that would cause changes changeable.a = 2; // save () is triggered! // j.a === 2
Note that the values of the original object also change – that's the beauty of Proxy! Also note that when changing is not indicated which property is changed; the use case, as Sindre describes, is to store an object (to server, etc.) when a part of an object changes. You could also use ti for a small library with a rendering function, where the content is redisplayed when a property is changed!
This exchange library is really nice if you do not have to know which house has changed, only that something has changed.