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

@computed with dotted property paths: clarify docs #76

Open
kwaclaw opened this issue Apr 4, 2016 · 2 comments
Open

@computed with dotted property paths: clarify docs #76

kwaclaw opened this issue Apr 4, 2016 · 2 comments

Comments

@kwaclaw
Copy link

kwaclaw commented Apr 4, 2016

Seems when the computed value is based on a sub-property, the @computed annotation style does not work. Maybe clarify in the documentation. Example:

    @property({ type: Object, notify: true })
    model: AppModel;

     // this does not compile
    @computed({ type: Boolean, notify: true })
    isAuthenticated(model.userProfile: any): boolean {
        return this.model.userProfile != null;
    }

    //this works
    @property({ type: Boolean, notify: true, computed: "getAuthenticated(model.userProfile)" })
    isAuthenticated: boolean;
    getAuthenticated(userProfile: any): boolean {
        return this.model.userProfile != null;
    }
@nippur72
Copy link
Owner

nippur72 commented Apr 4, 2016

that's because

isAuthenticated(model.userProfile: any): boolean { }

is not valid JavaScript/TypeScript.

But perhaps @computed can be modified so to accept a name or path, e.g.:

@computed({ type: Boolean, notify: true, path: "model.userProfile" })
    isAuthenticated(userProfile: any): boolean {
    }

@kwaclaw
Copy link
Author

kwaclaw commented Apr 4, 2016

Yeah, I understand why it would not work. The suggested approach looks reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants