vuex why no async in mutations (seems to work anyways)

Viewed 3085

I was wondering why all tutorials say that mutations cannot use async code.

I tried it and it obviously works:

mutations: {
    clearTodo(state) { setTimeout(() => state.todo = '', 1000) }
},

results in the same behaviour as:

mutations: {
    clearTodo(state) { state.todo = '' }
},
actions: {
    clearTodoAction({commit}) { setTimeout(() => commit('clearTodo'), 1000)}
}
1 Answers
Related