Thanks for quick reply,
how can I populate form fields by using msg in ui-template?
Edit:
managed to populate form with msg by directly accessing msg instead of creating temporary variables
watch: {
msg: function(){
this.barcode = this.msg.payload.barcode
}
},
@joepavitt I've also tried to use:
this.$socket.on('msg-input:' + this.id, this.handleMessage);
and I've noticed that watch persists field state after screen reload while $socket.on clears the field.
Is there documentation about Input message handling? best info I found while researching was:
and
maybe it would make sense to extend examples:
with ui-template example
<script>
export default {
data() {
// define variables available component-wide
// (in <template> and component functions)
return {
count: 0
}
},
watch: {
// watch for any changes of "count"
msg: function (){
//increase by incomming message
if(this.msg.payload === "increase") this.count++
//decrease by incomming message
if(this.msg.payload === "decrease") this.count--
},
count: function () {
if (this.count % 5 === 0) {
this.send({payload: 'Multiple of 5'})
}
}
},
computed: {
// automatically compute this variable
// whenever VueJS deems appropriate
formattedCount: function () {
return this.count + 'Apples'
}
},
methods: {
// expose a method to our <template> and Vue Application
increase: function () {
this.count++
}
},
mounted() {
// code here when the component is first loaded
},
unmounted() {
// code here when the component is removed from the Dashboard
// i.e. when the user navigates away from the page
}
}
</script>
just my 2 cents