Skip to content

phillipskevin/observable-decorators

Repository files navigation

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

About

Make class properties observable using decorators

Resources

License

Stars

Watchers

Forks

Packages

No packages published