0

I have two actions in two different modules:

unload: ({ commit, state }) => {
  console.log(this);
  commit('UNLOAD_LOCATIONS_GROUPED');
  Object.keys(state.providerList).forEach((npi) => {
    store.unregisterModule(`locationsGroup/providersList/${npi.toString()}`);
  });
},

unload({ getters, commit }) {
  console.log(this);
  getters.list.forEach((provider) => {
    this.unregisterModule(['providers', 'list', provider.npi]);
  });
  commit('UNLOAD_PROVIDERS');
},

When I see the value of this in the console, I see that one is the store(what I want) and the other is an object that seems to represent the module when logged looks like this {a: {...}} Diving into the later object looks like all the same properties of that actions module.

What is the context of this in an action or how is it derived? As it doesn't seem to be consistent.

Andrew Kim
  • 3,145
  • 4
  • 22
  • 42
  • 1
    Possible duplicate [Arrow function vs function declaration / expressions: Are they equivalent / exchangeable?](https://stackoverflow.com/questions/34361379/arrow-function-vs-function-declaration-expressions-are-they-equivalent-exch) – Vivick Jun 08 '18 at 22:41
  • oh my, i didn't even notice my typo there =( thanks so much – Andrew Kim Jun 08 '18 at 22:45

0 Answers0