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

1.0.0-beta.0 • Public • Published

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';
}

Package Sidebar

Install

npm i gweld

Weekly Downloads

1

Version

1.0.0-beta.0

License

MIT

Last publish

Collaborators

  • vuex