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

Implement more of the Vuex functionality #28

Open
asmadsen opened this issue Jun 16, 2019 · 0 comments
Open

Implement more of the Vuex functionality #28

asmadsen opened this issue Jun 16, 2019 · 0 comments

Comments

@asmadsen
Copy link
Contributor

The motivation of encapsulating more of the Vuex functionality is to extend the type-safety to more parts of Vuex.

Root Vuex Module

The first step would be to encapsulate the creation of the root Vuex module, then we can also pass pre-made proxies to actions and getters.
To do this we are missing options for plugins, strict, and devtools.

Class decorator

import { VuexClass } from 'vuex-class-component'

@Store({
  strict: boolean,
  devtools: boolean,
  plugins: Plugin<Store>[]
})
class Store extends VuexClass {
}

Constructor options

import { VuexClass } from 'vuex-class-component'

class Store extends VuexClass {
  constructor() {
    super({
      strict: boolean,
      devtools: boolean,
      plugins: Plugin<Store>[]
    })
  }
}

Configuring sub-modules

import { VuexClass } from 'vuex-class-component'

class Store extends VuexClass {
  auth = new AuthModule()
}

class AuthModule extends Store.SubModule(store => store.auth) {
}

Other possibilities

We could implement decorators for Watch, Subscribe, and SubscribeAction. This way we could have actions or mutations be called as reactions to other parts of the state without the origin knowing what methods to call after a change. I.e. Fetch different kinds data after login state changed/login action is called/login mutation is called without them knowing what actions or mutations that relies on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant