Views
are composition of multipleComponents
and typically represents anPage
orDialog
in the applicationComponents
are either one single UI component or composition of multiple smallComponents
representing one unit
Components
shall retrieve all data it needs through propsViews
shall retrieve states through use ofgetters
only
- API calls shall be done from the
Actions
only, flow will be as following:View
->Store Action
->Service
->Axios call
-> Response stored in theStore
(andlocal storage
if needed)
- Every API call shall update the
loading state
by using Axios interceptor, seeServices
inservice
folder
- In case where states has dependencies to each other, for instance changing
locale
state impactsgeolocation details
state, statewatch
shall be used and should be registered in thestore.ts
- States that must be initiated when application is refreshed/accessed for the first time shall be done in the Default.vue layout
- Static text that needs to be translated shall be stored in
locales
folder - Translations using
vue-i18n
can be done fromViews
andComponents
States
anddata
that does not update frequently (such as Homey geolocation coordinates or weather location details that needs to be persistent for longer period shall be stored in thelocal storage
, in addition to theStore
.- Use the
vuex-persist
library to avoid unecessary boilerplate code and do the configuration instore.ts
- Define and use
constants
when referring to Vuex Action, Mutation and Getter, these shall be stored in thestore
folder - Always return Promise in
Actions
so the caller know when the action is completed. Return value of Promise shall be empty if you are using getters to retrieve updated state Actions
shall usegetters
(orrootGetters
) to retrieve stateMutations
andGetters
shall only mutate and returnStore data
. If you for instance need to access or mutate data in local storage, do this in Actions