Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This switches Vuex to Pinia.
Vuex has always been a little confusing and overkill with its actions + mutations workflow. Now using Pinia it's much simpler.
Vuex was being used in a number of places in order to keep chunks of centralized data. In most places I've refactored away from using Vuex or Pinia at all. Instead, opting to use Vue's
ref
to keep a simple reactive array of stuff.The only real place that uses Pinia now is the publish component (which is used all over the place).
There are some simple breaking changes though.
The
this.$store
Vuex helper has been removed. Any components attempting to access the store were probably already getting the injectedstoreName
property. Now the actual Piniastore
itself will be provided. There's no need for thestoreName
property anymore if you were just using it to access the store.If you were using
Statamic.$store
, you should also be relying on the providedstore
.Similarly, in field actions you would get the store api and storeName in the payload. Now you get the store itself.
If you were dispatching actions or committing mutations, you will now call methods on the
store
directly.If you want to create your own store, you can now use Pinia yourself.
Contrary to the Pinia docs, you should not
npm require pinia
, and notimport { whatever } from 'pinia'
.Instead, use methods from
Statamic.$pinia
which ensures you are sharing the same instance of Pinia with Statamic.