0👍
You can’t, the async/await is a "Fake sync" apearence but in realy is a Async process, you can’t wait to finish, all vue enviroment will continue.
But you can use a correct use of Vuex to detect a change of store using getters, when you change a Data using a commit a "call change event" is fire across all getters functions and the change is reactive.
Please read the Vuex documentation and if you want a solution, please write the final propouse of lang variable.
EDIT:
I don’t know what are you using for i18n, but i think that vue-i18n can change on hot with location hot changes:
0👍
you can use .then and finally
await this.device.getLanguageCode()
.then(({ data }) => {
lang.value != "en" && lang.value != "fr"
? this.$store.commit("setLang", "en")
: this.$store.commit("setLang", lang.value);
})
.catch(function(error) {
console.log(error);
}).finally(()=>{
});
- [Vuejs]-Is lazy loading B64 images from vuex Store possible?
- [Vuejs]-How to properly configure my backend in order to receive data from my form? I'm using Vue.js
Source:stackexchange.com