79613663

Date: 2025-05-09 07:35:05
Score: 1.5
Natty:
Report link

It turns out that this is a limitation in pinia setup stores.

My currentlyAnOptionsStore has an action theMotherAction calling functionA and functionB in a setup store $onAction is not triggered if a store calls its own action :(

export const useMyStore = defineStore('myStore', () => {
  const functionA = (data) => {
    // do stuff
  }
  const theMotherAction = (msg) => {  
    const data = msg.data;  
    functionA(data);
  }
  return {functionA, theMotherAction}
})

One can solve it rather ugly by calling useMyStore in the mother action like this

const theMotherAction = (msg) => {  
  const data = msg.data;  
  useMyStore().functionA(data);
}

I'm considering reverting back to use an options store

Reasons:
  • Blacklisted phrase (1): :(
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Madelaine