vue-async-computed-decorator
vue-async-computed-decorator copied to clipboard
How to access to instance component in AsyncComputed decorator ? (TSLint)
Hello,
Thanks for the work on the AsyncComputed
decorator.
I would like to use the decorator's shouldUpdate function but I cannot access the current component instance. The code works but the TSLint linter is not happy
export default class CardsPage extends Vue {
// ...
@Inject()
private getCardsUseCase!: GetCardsUseCase;
public foo: boolean = true;
@AsyncComputed({
shouldUpdate() {
return this.foo;
},
})
async cards(): Promise<CardView[]> {
return this.getCardsUseCase.execute('azerty123');
}
// ...
}
ERROR in /../../src/UI/Page/Cards.vue(81,19):
81:19 Property 'foo' does not exist on type 'IAsyncComputedOptions<TResult>'.
79 | @AsyncComputed({
80 | shouldUpdate() {
> 81 | return this.foo;
| ^
82 | },
83 | })
84 | async cards(): Promise<CardView[]> {
ERROR in /../../src/UI/Page/Cards.vue(81,19):
81:19 Property 'foo' does not exist on type 'IAsyncComputedOptions<unknown>'.
79 | @AsyncComputed({
80 | shouldUpdate() {
> 81 | return this.foo;
| ^
82 | },
83 | })
84 | async cards(): Promise<CardView[]> {
Version: typescript 3.9.7
I also tried by adding the type of the VueJS component after the decorator declaration but without success... @AsyncComputed<CardsPage>({ //... })
Do you have any idea for this?
Thank you