DEV Community

Fabio Franchino
Fabio Franchino

Posted on

1

Vue.js dependency dilemma

During a Vue.js project, I'm asking all the time this question:

Where to insert the Vuex (store) dependency in components?

It's very easy and fast binding a Vuex getter to computed props in components, this way the component in not anymore totally decoupled.

What's your best practice when a little button needs to emit an action to modify a property? You can:

  • allow the button to commit straight to the store
  • walk the whole hierarchy component tree in order to reach a root component/view that is enabled to commit the store?

Any hints?

Top comments (1)

Collapse
 
ehutch79 profile image
Eric Hutchinson

VueX is a global store. If it's a global object, there's no reason the button component shouldn't commit the action.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay