observer-object
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Object watcher

Object watcher is library used to add a watercher on object. Whenever object properties being read or write get callback & set callback will be notified with the object property. This library will not make any changes on exisiting structure of the object Object read or set new values to objects are same as read

Commands

library code inside /src. examples are provided inside /src/examples.

Example 1

const ObjectWatcher = require('object-watcher').default;

const objectToWatch = {
    carName: 'Tesla',
    modelName: 'Model X'
};

function getterFunction(key, value) {
    console.log(`called getter function ${key}, ${value}`);
}

function setterFunction(key, oldValue, newValue) {
    console.log(`called setter function, key ${key}, oldValue ${oldValue}, newValue ${newValue}`);
}

const objectPropertyWatcher = new ObjectWatcher(objectToWatch, getterFunction, setterFunction);
objectPropertyWatcher.carName;
objectPropertyWatcher.modelName = 'Model Y';

Package Sidebar

Install

npm i observer-object

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

18.5 kB

Total Files

11

Last publish

Collaborators

  • ganeshpatil0101