DEV Community

Discussion on: How I'm using Vue Slots on my site

Collapse
 
chiubaca profile image
Alex Chiu

Yay for Vue tidbits! Look forward to more! can you do one on plugins vs mixins ? I never know which to use

Collapse
 
samanthaming profile image
Samantha Ming

Ah mixins is my headache 😣 BUT I’m recently learning the new Vue composition API which solves some of the concern of mixins, so cant wait to be able to use that!

In regards to plugins, can you expand more? So I know content to better create πŸ™‚

Collapse
 
chiubaca profile image
Alex Chiu

Yes of course, so for example in one of my early Vue projects where I had no idea what i was doing. I started writing a mixin which handles all of my HTTP requests to firebase.

I noticed in other projects , this was handled much better as plugin instead, this allowed for you to extend the Vue object, so you could do something like this.$http.get() or this.$http.post() etc inside a vue component. This seems a lot cleaner! It's left me wondering in which circumstance would a mixin be better choice over a plugin? like you said, perhaps mixins are going out the door with vue 3?

Thread Thread
 
samanthaming profile image
Samantha Ming

Ah gotcha! Thanks for clarifying! That's a good question -- I have been avoiding mixins so I'm not sure when it is advantageous πŸ€” Let me dig into it and see what I find πŸ‘