-
Notifications
You must be signed in to change notification settings - Fork 66
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
Executed without being called, normal computed works different #98
Comments
You're right that this is a slight difference in behavior. It is, however, necessary. Let's take your example. Imagine we're writing a method like this:
This works fine, whenever you call
But that said, sometimes what you want is to simulate that: to access a value that is calculated asynchronously from a synchronous context. But because you can't actually block the synchronous context to calculate an async value, the only way to do that is to calculate the async value up front (and to keep it updated as the dependencies change, of course.) That's what
This isn't exactly the same: specifically the part about the value being It's a reasonable question to ask whether One way or another, it's always an option. If you'd like, just
This should give you roughly the the behavior you're looking for, with the caveat I mentioned above about the initil value of |
Wow, thank you for the well explained answer! |
When I put this in a component without calling any of these properties I'm getting a
test1
alert. Why is a async computed property executed without being called and a normal computed property not?The text was updated successfully, but these errors were encountered: