#VueJS : Mixins vs Composition API

8 messages · Page 1 of 1 (latest)

signal pumice
#

Hello guys and gals (and everyone else).
For a Django DRF project with VueJS 3 as a frontend framework :

I have a need to declare and use a selected cinema variable (session variable) and I don't want to repeat my code fetching or updating said selected_cinema to stick to DRY principles.

What would be preferable : mixins or composition API ?

signal breach
#

the options API is easy to understand from what I recall, but has some drawbacks as your app grows and you use more and more mixins to reuse code. it can be hard to separate features like this and you may easily override/shadow fields/methods by accident as there's nothing preventing it

#

the composition API helps with that but overall looks more abstract and technical to me

#

not sure if you can use it outside of .vue files which need a build pipeline

signal pumice
#

Yeah I had read this.

Right now I have my views in option API. The third file for code factorization just contains functions. I'm just wondering which one I should chose.

signal pumice
#

As I'm using Vue from CDN for now, it could be an issue