-
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
I think computed method shouldn't have side effect #30
Comments
Well, you certainly don't have to use Not every Vue plugin fits with everybody's preferred style, so it's perfectly fine that this one doesn't fit with yours. For what it's worth, I agree with you that computed methods shouldn't try to avoid changing state, either locally or remotely. But there's still plenty of room for making API calls that are safe and idempotent, such as HTTP GET requests. Such computed properties are, in my opinion, not really any less pure than ones which depend purely on local state. Yes, behind the scenes there is some hidden state (that I think there is power in such abstractions. Vue itself keeps and modifies some hidden state when watching for data changes, and that's fine: the interface that it exposes uses these implementation details behind the scenes, but doesn't expose them. My goal is for Of course, it's OK to disagree: if you feel that you don't want to use this plugin, there's nothing wrong with that, and you are certainly free to write your own Vue applications in whatever way you feel is best for you. But I do hope that you understand a bit better now, after my explanation, why I don't think that there is anything wrong with asynchronous computed methods, if used responsibly. |
Thanks for your patiently reply, I get a better understanding of your design purpose. I think it fine to handle GET requests or something like that ( just like you said, you handle the hidden state for users, make a easy to use api ). It's cool to share your thoughts, thanks for your work |
Thanks for all of your work, but I think making computed method async is anti vue's design. In my opinion, I think computed method shouldn't change any state or make api call. If you must, I think you'd better use 'watch' instead.
The text was updated successfully, but these errors were encountered: