vue3-task-manager
vue3-task-manager copied to clipboard
[Question] - Action Typing and Payloads
I was reading your article (great, btw!) and following along. I noticed that you specify the type as ActionTree<State, State> & Actions
.
But if you wanted to do an action with a payload, such as a login function similar to:
async [ActionTypes.Login]({ commit }, {username, password}) { AuthService.login(username, password).subscribe(res => { commit(MutationType.SetUsername, res.username); commit(MutationType.SetIsLoggedIn, true); }) }
You would recieve an error because the payload {username, password} was unexpected. Removing the & Actions
stops the error.
I'm still pretty new to Vuex (and fully appreciating strong typing), am I approaching this incorrectly?