An ES6 Module to observe properties (simple properties, Arrays, Sets and Maps) of an Object. Can also intercept function calls.
Observing means to call a callback-function every value change of an Object property.
Observe properties (attributes) of an object. Works also with Arrays, Maps and Sets.
The parameter propertyName
can be an array of names to observe multiple properties.
{ propertyName: propertyName, oldValue: oldValue, newValue: newValue }
Observe.property(model, ["property1","property2"], (params) => {
console.log("property changed", params.propertyName);
console.log("oldValue", params.oldValue);
console.log("newValue", params.newValue);
})
Intercept a function call, before the function is executed. Can manipulate arguments in the callback.
{functionName: functionName, arguments: functionArguments}
Intercept a function call, after the function is executed. Can manipulate returnValue in callback.
{functionName: functionName, arguments: functionArguments, returnValue: returnValue}