Skip to content

is it possible to add "middleware" inside actions #1988

Discussion options

You must be logged in to vote
  store.$onAction((it) => {
    // react to store actions
    it.store.loading = true
    console.log('before', it)
    it.after(() => {
      console.log('after', it)
      it.store.loading = false
    })
  })

i just replace my withLoader function, and did this instead
basically the onAction function trigerred everytime we call the action.
and the after function works after the action finish to execute

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by RobyCigar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant