1.0.0-beta.0 • Published 7 years ago
gweld v1.0.0-beta.0
Gweld
A small library to react to changes on object properties
Install
npm i -S gweld
Usage
import { watch, observable } from 'gweld';
const myObj = { foo: 'bar' };
observable(myObj, 'foo');
const stopWatching = watch(myObj, 'foo', (value, prev) => {
console.log(`foo changed from ${prev} to ${value}`)
});
myObj.foo = 'baz'; // => foo changed from bar to baz
myObj.foo = 'foobar'; // => foo changed from baz to foobar
stopWatching();
myObj.foo = 'foobaz';
// observable can also be used as a decorator, e.g.
class MyClass {
@observable foo = 'bar';
}
1.0.0-beta.1
7 years ago
1.0.0-beta.0
7 years ago