44

Function-based Component API by yyx990803 · Pull Request #42 · vuejs/rfcs · GitH...

 4 years ago
source link: https://github.com/vuejs/rfcs/pull/42#issuecomment-504963168
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
A proposal that consolidates upon #22 (Advanced Reactivity API), #23 (Dynamic Lifecycle Injection) and the discontinuation of #17 (Class API).Full Rendered ProposalHigh-level Q&AIs this like Python 3 / Angular 2 / Do I have to rewrite all my code?No. The new API is 100% compatible with current syntax and purely additive. All new additions are contained within the new setup() function. Nothing is being removed or deprecated (in this RFC), nor do we have plan to remove / deprecate anything in the foreseeable future. (A previous draft of this RFC indicated that there is the possibility of deprecating a number of 2.x options in a future major release, which has been redacted based on user feedback.)DetailsIs this set in stone?No. This is an RFC (Request for Comments) - as long as this pull request is still open, this is just a proposal for soliciting feedback. We encourage you to voice your opinion, but please actually read the RFC itself before commenting, as the information you got from a random Reddit/HN thread can be incomplete, outdated or outright misleading.Vue is all about simplicity and this RFC is not.RFCs are written for implementors and advanced users who are aware of the internal design constraints of the framework. It focuses on the technical details, and has to be extremely thorough and cover all possible edge cases, which is why it may seem complex at first glance.We will provide tutorials targeting normal users which will be much easier to follow along with. In the meanwhile, check out some examples to see if the new API really makes things more complex.I don't see what problems this proposal solves.Please read this reply.This will lead to spaghetti code and is much harder to read.Please read this section and this reply.The Class API is much better!We respectfully disagree.This RFC also provides strictly superior logic composition and better type inference than the Class API. As it stands, the only "advantage" the Class API has is familiarity - and we don't believe it's enough to outweigh the benefits this RFC provides over it.This looks like React, why don't I just use React?First, the template syntax doesn't change, and you are not forced to use this API for your <script> sections at all.Second, if you use React, you'll most likely be using React Hooks. This API is certainly inspired by React hooks, but it works fundamentally differently and is rooted in Vue's very own reactivity system. In addition, we believe this API addresses a number of important usability issues in React Hooks. If you cannot put up with this API, you will most likely dislike React Hooks even more.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK