Skip to content

this.$asyncComputed.name.update() doesn't allow to access Vue this. #60

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

Closed
KubasGC opened this issue Jan 10, 2019 · 4 comments
Closed

Comments

@KubasGC
Copy link

KubasGC commented Jan 10, 2019

I'm using async computed property like this:

asyncComputed:
        {
            perms:
            {
                lazy: true,
                async get()
                {
                    return (await DelegationsService.getPermissions(this.$route.params.delegationId)).data;
                },
                default:
                {
                    accept: false,
                    edit: false,
                    settlement: false,
                    isOwner: false
                }
            }
        }

It works fine, but when I'm using function this.$asyncComputed.perms.update() inside method, I have got an error called that I have no access to this entity,

@foxbenjaminfox
Copy link
Owner

I'm trying to reproduce the bug, but I'm not quite managing. Do you have a minimal replication of the issue you could share? Or even just more detail about what causes the error.

@yancyknight
Copy link

I ran into this problem as well. Here's a code pen I made showing the issue. When update is called, the get function runs twice, but the first time this points to the window, not the Vue instance.
https://codepen.io/yancyknight/pen/LqOEpR?editors=1010

@foxbenjaminfox
Copy link
Owner

OK, now I see. This is actually a duplicate of #53, which was fixed in #54, which was included in v3.5.1. If you upgrade to the latest version of vue-async-computed, that will fix the problem.

@yancyknight: thanks for making the code pen with the demonstration of the issue. It was very helpful in making it clear what exactly the problem was, and how it was the same as issue #53.

@yancyknight
Copy link

The new version works great, thank you!

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

3 participants