-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Access non-decorated function #335
Comments
@eikebartels as far as I know: non decorated functions are stripped of when a module gets converted (e,g. only getters, actions, mutation methods will remain) - someone please correct me if I am wrong.
Move these non-decorated functions outside of the class module and call them directly (just like helper functions). Something like this: function toUpperCase(value: string): string {
return value.toUpperCase();
}
@Module({
store,
dynamic: true,
namespaced: true,
name: "foo",
})
export default class FooModule extends VuexModule {
@Action({ rawError: true })
async doSomething(data: { email: string }) {
const awesomeEmail = toUpperCase(data.email);
// do whatever you wish with the converted string
}
} |
It appears @fen89 is correct. I for some reason tried to do the same thing. I moved my function to the top and it worked a treat! |
One way to make it possible is by decorate a private function like:
|
This is should be considered a bug, for two main reasons:
Stripping code from the original class seems like a terrible idea that can only cause headaches to the users. At the very least, private methods should be kept, since their very purpose is to be called by other methods. |
@eikebartels I've tried your suggestion of annotating a private function with |
@eikebartels I'm trying to call my private function from a |
I think I understand now. |
I'm not sure the work around works when you want to call non-decorated private functions from a mutation rather than from an action. I've got some helper functions that need to be able to both get and set state and I can't call them from my mutation |
First of all, thanks for this sweet library!
I start using it and I don't get one thing. I have the following:
When I call
makeAwsomeString
from anAction
I'm getting:error in v-on handler (promise/async): "typeerror: makeAwsomeString is not a function"
Whats the issue here and how can I solve it?
The text was updated successfully, but these errors were encountered: