Skip to content

Best practices for manipulating state on or immediately after read (getters) #696

Discussion options

You must be logged in to vote

There's a lot of ways to go about this, as far as best practices go you don't want to have side effects in a getter, so if you do need to have a side effect an action would be better. There's nothing wrong with returning some portion of the state at the same time as manipulating the store.
Or you could just read and manipulate the store state directly which isn't a problem in Pinia like it was in Vuex, unless you want to be very explicit by only using actions which some prefer.
Having the business logic in the consuming component is a matter of preference, personally in this case only 1 component would be reading the notifications, so to me it makes sense to keep that logic within the com…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thebleucheese
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants