observable-decorators

0.0.2 • Public • Published

observable-decorators

Build Status

Make class properties observable using decorators

Usage

import observable from 'observable-decorators';
 
class Person {
  constructor(override) {
    Object.assign(this, override);
  }
 
  @observable
  first = 'Kevin';
 
  @observable
  last = 'Phillips';
 
  @observable
  get fullName() {
    return this.first.combineLatest(this.last, (first, last) => {
      return first + ' ' + last;
    });
  }
}
 
const person = new Person({
  first: 'Kevin'
});
 
person.fullName.subscribe((fullName) => {
  // 'Kevin Phillips',
  // 'Kevin McCallister'
});
 
person.last = 'McCallister';

Readme

Keywords

none

Package Sidebar

Install

npm i observable-decorators

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • phillipskevin