Skip to content

Why do we allow a dispatch to return a promise that can be chained? #2060

@Joralf

Description

@Joralf

From the documentation (https://vuex.vuejs.org/guide/actions.html#composing-actions)

The first thing to know is that store.dispatch can handle Promise returned by the triggered action handler and it also returns Promise:

store.dispatch('actionA').then(() => {
  // ...
})

This opens up the possibility for a component to "do stuff" after a promise was resolved or rejected. Imho this breaks the unidirectional pattern, cause the component will react to the result of the asynchronous action instead of the state of the store. What was the reasoning behind this decision and what are your views on the above statement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions