Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 772 Bytes

README.md

File metadata and controls

41 lines (30 loc) · 772 Bytes

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