I need clarifications about accessing the store actions in the return of the setup function #540
-
|
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.
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.
In JS, functions using
thismust be called wiht the object:store.someAction(), otherwisethis(the context) won't have the same value.Just return the whole store in
setup:setup() { const settings = useSettingsStore(); return { - setPlatformName : settings.setPlatformName, // <= setPlatformName is a simple action + settings, } }And then do
@click="settings.setPlatformName(theName)"You can also do
To set the
thisvalue