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

how to set cache to false for computed property #10

Open
noteon opened this issue Aug 3, 2016 · 1 comment
Open

how to set cache to false for computed property #10

noteon opened this issue Aug 3, 2016 · 1 comment

Comments

@noteon
Copy link

noteon commented Aug 3, 2016

e.g.
computed: {

  example: {
     cache: false, //no cache 
     get: function () {
       return Date.now() + this.msg
    }
  }
}

in vue-typescript, how to get this feature by using decorator?

@itsfrank
Copy link
Owner

itsfrank commented Aug 3, 2016

Hmm, this was an oversight. For now if the property is only used in the template, you can define it in the decorator:

If the property is used in code you will have to cast 'this' like so: (<any>this).a for now just declare a variable of the same name and type (dont assign it a value, just declare it).

@VueComponent({
    computed: {
        a: {
            cache:false,
            get:function(){return 'hello'}
        }
    }
})
export class Component{

   a:string;

    ready(){
        console.log(this.a) //<will get the computed function above
    }
}

Ill think of a solution and reply here when i have one, this will probably require the addition of a new decorator. Putting @Copmuted({}) above the getter or setter most probably

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