API Composition Video Tutorial

If you follow the news around VueJS you must have heard about a major change in the API's operation. Recently renamed API Composition, this API will help better organize its code and create reusable logic.

Still change?

Do not panic ! The first version of the API was very disruptive but was changed following feedback from the community (it was also to get feedback that the API was offered in "Request Fgold VScomments ").

  • The new RFC, renamed API Composition View, is thought to be additive and will work in addition to the existing API. It will not be necessary to completely rewrite your old components.
  • ViewJS remains ViewJS. Even if the API proposes a different logic the concepts that you know today remain the same (computed, mounted, unmounted ...).

What is the goal ?

The purpose of the API composition is to better organize its code and avoid the problem of "monster component". Indeed, the current operation forces us to scatter the logic of our component in the different properties (methods, data, onMounted...).

The code can now be gathered in one function setup ().

But mostly separated into functions, which can be reused in several components if necessary.