Giter Site home page Giter Site logo

observable-objects's Introduction

bigab

Just reserving this package name on npm

observable-objects's People

Contributors

bigab avatar

Stargazers

 avatar

Watchers

 avatar

observable-objects's Issues

Deep changes should be observable

When a child object or array has a property changed, the observable should emit an event with the appropriate path value of the change

Should `get` accessors allow deriving from other observables and child object props?

Like in CanJS should you be able to do something like:

@observable
class MyThing {
  userAccount = UserAccount.getActiveUser(),
  get fullname() {
    return `${this.userAccount.firstName} ${this.userAccount.lastName}`
  }
}

const thing = new MyThing();
Observable.of(thing).subscribe({
  next(e){ console.log(e.target.fullname) }
});
 console.log( thing.fullname ) // Logs: Adam Barrett
const activeUser = UserAccount.getActiveUser();
activeUser.firstName = 'Isla'  // Logs: Isla Barrett

...where instances of UserAccount are also observables, and so any change to them will actually end up triggering a change in the thing instance because of the "derived" or "computed" property?

If so, would it also be a good Idea to implement a @lazy decorator for such accessor properties so that that we could cache the last value, and only update that value when an internal observable emits a 'relevant' change.

@observable
class MyThing {
  userAccount = UserAccount.getActiveUser(),

  @lazy
  get fullname() {
    return `${this.userAccount.firstName} ${this.userAccount.lastName}`
  }
}

I think it would be a good idea, but it sounds like a lot of work.

The target in the emitted event should be read-only

The target property emitted in the event should not allow mutation.

I think the best option is for target to be a proxy to the source, with a proxy tree just like the actual observable proxy, except that all set's get trapped and no-op (or warn)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.