Description
Is your feature request related to a problem? Please describe...
It is not related to a problem. In pure Vue + Vuex setups, I normally define "pending flags" in each module's state. These pending flags are used to track whether an API call is in progress, for example fetchingUserPending
. I set these to false at the beginning of an action and to true in both the .then
and .catch
callbacks.
Describe the solution you'd like
I would be nice to have default pending flags defined for each model and each api call type in the Vuex ORM database, which are then controlled by the Vuex ORM axios plugin. Examples would be:
fetchingPending
, updatingPending
etc.
Describe alternatives you've considered
Manually adding state variables like this
class User extends Model {
static entity = 'users'
static state () {
return {
fetching: false
}
}
static fields () {
return { ... }
}
}
and updating them whenever doing an api call:
User.commit((state) => {
state.fetching = true
})
User.all().then(_ => {
User.commit((state) => {
state.fetching = false
})
}
.catch(_ => {
User.commit((state) => {
state.fetching = false
})
}
This is quite cumbersome, it kind of defeats the whole purpose of using this plugin since I might as well manually define actions.