How to subscribe to a specific action in Pinia

Viewed 550

Does anyone know if it's possible to subscribe to a specific action in Pinia? I know there's a way to subscribe to all actions like this:

const subscribe = someStore.$onAction(callback, false)

But that means I have to compare action name to the one I want within the callback, like this:

websocketStore.$onAction(
  ({name}) => {
    if (name === 'specificAction') {
      console.log('do something')
    }
  }
)

So I wonder if there's a way to it better? (I'm using Pinia with Nuxt3)

0 Answers
Related