New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define getters throw two events #1585

Closed
justinbmeyer opened this Issue Apr 1, 2015 · 0 comments

Comments

Projects
None yet
2 participants
@justinbmeyer
Contributor

justinbmeyer commented Apr 1, 2015

Something like:

var AppState = can.Map.extend({
  define: {
    person: {
      get: function(lastSetValue, setAttrValue ) {
        if(lastSetValue) {
          return lastSetValue;
        } else if(this.attr("personId")){
          Person.findOne({id: this.attr("personId")})
            .then(setAttrValue)
        } else {
          return null;
        }
      }
    }
  }
});

If personId is set, person will fire two events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment