question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: subscribeAction()

See original GitHub issue

VueX has an option to subscribeAction. I think it would be even more relevant here. Pinia currently has subscribe() but it’s just a simple wrapper over watch() and it often might not be precise enough.

Subscribing to actions would be more explicit.

https://vuex.vuejs.org/api/#subscribeaction

store.subscribeAction((action, state) => {
  console.log(action.type)
  console.log(action.payload)
})

Usecase:

In many places in the code you might want to react to userStore.state.isLoggedIn. Current store.subscribe() may fire multiple times, you’d need to check for truthy value of loggedIn, check if it’s different from previous value and so on.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
posvacommented, Jun 3, 2021

The API has been documneted

3reactions
gjuchaultcommented, Oct 23, 2020

@posva Use case: making plugins like persistance, logging, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request: subscribeAction() · Issue #240 · vuejs/pinia
VueX has an option to subscribeAction . I think it would be even more relevant here. Pinia currently has subscribe() but it's just...
Read more >
Subscribe - Amazon Simple Notification Service
Subscribes an endpoint to an Amazon SNS topic. If the endpoint type is HTTP/S or email, or if the endpoint and the topic...
Read more >
Bountysource
Feature request : subscribeAction() ... Help and Information. Frequently Asked Questions · Bugs and Feature Requests · Fees ...
Read more >
Feature Request Content - Instabug
This page covers the content found in a feature request. Suggest Edits. Users can add new feature requests or comment on existing ones....
Read more >
API Reference | Vuex
The subscribeAction method will return an unsubscribe function, which should be called when the subscription is no longer needed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found