Vue.js[vuex] how to dispatch from a mutation?

Mutations can’t dispatch further actions, but actions can dispatch other actions. So one option is to have an action commit the mutation then trigger the filter action. Another option, if possible, would be to have all filters be getters that just naturally react to data changes like a computed property would. Example of actions calling … Read more

What is the Vuex “context” object?

From the documentation you pointed out you can read: We will see why this context object is not the store instance itself when we introduce Modules later. The main idea of the context object is to abstract the scope of the current Module. If you simply access store.state, it will always be the root state. … Read more

How should I handle events in Vuex?

Vuex and event bus are two different things in the sense that vuex manages central state of your application while event bus is used to communicate between different components of your app. You can execute vuex mutation or actions from a component and also raise events from vuex’s actions. As the docs says: Actions are … Read more

Separating vuex stores for dynamically created components

For the first operation of NEW button – generating components – we add mutation to our store.js mutations: { addJob (state) { state.jobs.push(state.jobs.length + 1) … } Second, creating local modules. Here we’re going to use reusableModule to generated multiple instances of a module. That module we keep in separate file for convinience. Also, note … Read more

$store properties are not reactive when using computed property (Vuex)

Your code should work if you setup everything correctly: http://codepen.io/CodinCat/pen/RKZeZe?editors=1010 A very common mistake is that you didn’t give your state initial data. You should declare the state shape explicitly, so instead of state: {} // or state: { nav: {} } do this: state: { nav: { type: ‘…’ }, … } or the … Read more

How to access async store data in vue-router for usage in beforeEnter hook?

You can do it by returning a promise from vuex action, as it is explained here and call the dispatch from within the beforeEnter itself. Code should look like following: import store from ‘./vuex/store’; // following is an excerpt of the routes object: { path: ‘/example’, component: Example, beforeEnter: (to, from, next) => { store.dispatch(‘initApp’).then(response … Read more

Visual Studio Code breakpoint appearing in wrong place

To answer this for any particular case, one would need the launch.json configuration being used, and the source folder structure, at minimum. I have a true story from just last week to illustrate why: Background I recently inherited a relatively small Vue project, and immediately encountered the same problem. Breakpoints in VSCode were “jumpy” in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)