We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is there an example how to use the vue-mqtt in combination with the vuex ?
The text was updated successfully, but these errors were encountered:
In the App.vue in the mounted() block you can subscribe to mqtt topics.
mounted() { this.$mqtt.subscribe('topic/#') }
Then also in the App.vue in the mqtt block you can update certain veux state values using a comit, for example:
mqtt: { 'topic/#'(data, topic) { this.$store.commit('updateState', data) } }
Your store would look something like that:
import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ state: { topicValue: null }, mutations: { updateState(state, payload) { state.topicValue = payload } } })
Finally, in any component you can map the store state:
import { mapState } from 'vuex' export default { computed: { ...mapState(['topicValue']) } }
I hope, this answers your question.
Sorry, something went wrong.
No branches or pull requests
Is there an example how to use the vue-mqtt in combination with the vuex ?
The text was updated successfully, but these errors were encountered: