I need clarifications about accessing the store actions in the return of the setup function #540
Answered
by
posva
stephane303
asked this question in
Help and Questions
-
I tried to do this with my store:
and then calling directly setPlatformName from my component didnt' work, without any error message. I inspected the state and it was not changed. I guess it's related to the fact that settings (store) in an object wrapped with reactive. I had to write this:
Where can I get more information to fully understand what is going on, thank you. |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Jun 17, 2021
Replies: 1 comment
-
In JS, functions using Just return the whole store in setup() {
const settings = useSettingsStore();
return {
- setPlatformName : settings.setPlatformName, // <= setPlatformName is a simple action
+ settings,
}
} And then do You can also do setPlatformName: settings.setPlatformName.bind(settings) To set the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In JS, functions using
this
must be called wiht the object:store.someAction()
, otherwisethis
(the context) won't have the same value.Just return the whole store in
setup
:And then do
@click="settings.setPlatformName(theName)"
You can also do
To set the
this
value