0.0.1 • Published 7 years ago

observable-objects v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

observable-objects

Build Status

Create objects that you can subscribe to any property changes

@observable
class MyObservableClass {}
const obsObj = new MyObservableClass();

Rx.Observable.from(obsObj)
  .filter(({ path }) => path === "property")
  .map(({ newVal }) => newVal)
  .take(2)
  .subscribe({
    next(v) { console.log(v) }
  });

obsObj.property = "1 val";
obsObj.someOtherProp = 3;
obsObj.property = 2;
obsObj.property = "too many changes";

/*
    Logs:
      "1 val"
      2
 */