K
K
KondakovVladimir2020-12-03 00:06:55
Vue.js
KondakovVladimir, 2020-12-03 00:06:55

How to trigger a mutation in another module?

Hello.
I understand with vuex and it's not very clear how to solve the problem and whether I'm doing garbage at all. I
want to make an application (as usual a problem book). Actually, we have the tasks themselves that we want to store locally on the client (for example, in indexdb). The opening of this base is asynchronous code - that is, it must occur in an action. The link to the DB is part of the state - that is, you can assign the link using a mutation. And it seems clear how to do it inside the module.
But if you imagine that there are two modules operating with data (one stores tasks as such, the other stores information about when they were solved), you must either open the database twice, or somehow assign a link to the state in another module. - but it doesn't work

Tried to do mapMutations - but that didn't help either.
I will be grateful for any hints including an example of similar code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Just Me, 2020-12-03
@Just__Den

module 1

export const actions = {
  createSmth({commits, dispatch}, data){
    dispatch('actionOfAnotherModule')
  }
}

unit 2
export const actions = {
  actionOfAnotherModule({commits}, data){
    ...
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question