-
Notifications
You must be signed in to change notification settings - Fork 21
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
Feature request: create proxy inside of VuexModule #21
Comments
asmadsen
added a commit
to asmadsen/vuex-class-component
that referenced
this issue
May 8, 2019
@cmeyertons With #23 you can create a proxy from inside your actions, like so: @Module({ namespacedPath: 'subscriptions/' })
export class SubscriptionStore extends VuexModule {
@getter items: Product[] = []
@mutation
loadItems (items: Product[]) {
this.items = items
}
@action
load (): Promise<void> {
const productStore = ProductStore.CreateProxy(this.$store, ProductStore)
const query = bodybuilder()
.query('match', 'category.name', 'Subscriptions')
.build()
return productStore.list({query, start: 0, size: 10, updateState: false }}
.then(resp => {
const subscriptions = (resp.items as Product[]).sort((p1, p2) => +p1.order - (+p2.order))
this.loadItems(subscriptions)
}).catch((err) => {
console.error(err)
})
}
} |
awesome! do you happen to know what version this will be released in? |
I'm pretty sure it's already in the latest version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow this library is fantastic -- makes working with vuex modules much more intuitive and easy to use w/ type safety and intellisense!
The first module I implemented had to call out to another module that houses same shared logic, so I implemented using the raw action context, which worked but I lost all the type safety
Would it be possible to create a proxy that takes a VuexModule as a constructor? So inside my subscription vuex module it would look like:
Could that proxy method leverage the raw context to generate the necessary proxy? And then you have all the type safety you need when dispatching an action to another module
The text was updated successfully, but these errors were encountered: