Skip to content
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 · Fixed by #1587
Closed

define getters throw two events #1585

justinbmeyer opened this issue Apr 1, 2015 · 0 comments · Fixed by #1587
Assignees
Labels
Milestone

Comments

@justinbmeyer
Copy link
Contributor

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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants