Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate/Breakdown store vuex file to make cleaner #513

Open
bsor-dev opened this issue Jul 10, 2021 · 0 comments
Open

Separate/Breakdown store vuex file to make cleaner #513

bsor-dev opened this issue Jul 10, 2021 · 0 comments
Labels
feature request Feature request

Comments

@bsor-dev
Copy link

In NuxtJS its easy to breakdown vuex file into separate files like e.g

📦store
┣ 📂auth
┣ 📂utils
┣ 📂posts
┃ ┗ 📜actions.js
┃ ┗ 📜mutations.js
┃ ┗ 📜getters.js
┃ ┗ 📜index.js
┣ index.js

These are what I commonly doing in JS version. Here in nuxt typescript I tried to do same thing but don't know how to properly export actions mutations and getters

under store/user/index.ts is working fine.

export const state = () => ({
  things: [] as string[],
  name: 'Me',
})

export type RootState = ReturnType<typeof state>

I tried to do in action but I got an error actions should be function or object with "handler" function but "actions.action" in module "user" is {}

import { ActionTree } from 'vuex'
import { RootState } from '.'

export const action: ActionTree<RootState, any> = {
  async fetchThings({ commit }) {
    await Promise.resolve('data')
    commit('CHANGE_NAME', 'New name')
  },
}

@bsor-dev bsor-dev added the feature request Feature request label Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

1 participant