A few alternatives to Vuex state management in Vue application
YOU MIGHT NOT NEEDVUEX
View Slide
YOU MIGHT NOT NEEDVUE
Core Team MemberMy name isNatalia TepluhinaGoogle Developer ExpertSenior Frontend Engineer@N_Tepluhina
Do I needa shared state?
““Flux libraries are like glasses:you'll know when you need them”Dan Abramov
Independent componentsDifferent routesDeep nesting
Provide/injectapproach
ProvideInject
Reactive object
Don’t change datawhere it’s injected!
Composition APIto the rescue
posva/piniaAutomatically typed,modular and lightweightstore for Vue using theComposition api withDevTools supportEduardoSan Martin Morote
Creating a store
Using a store in components
DEMO
Let’s get someGraphQL hype!
vue-apolloIntegrates Apollo inyour Vue components withdeclarative queries.Compatible with Vue 2.0+and 3.0+. Guillaume Chau
Dispatch anactionTriggerAPI callSuccess?Commit‘success’mutationStatechangedCommit‘error’mutationYesNo
Query Success/errorStatechanged
Ok but what aboutlocal state?
Local state* = Apollo Cache*everything is Apollo Cache
‘Normal’ query…
..vs local query
Setting initial state
Changing data
Read the cacheUpdate dataWrite back to the cache
Thanks!You can find demo repository atbit.ly/no-vuex