I'm trying to use Electron's ipcRenderer inside my Vue sigle file component to populate some data. It easy enough to call out with a ipcRenderer.send(...)
but on the reply I want to update each instance of my component with the response message. I think the comment in ipcRenderer.on(...)
explains my issue the best. Is there a good way to do this. I'm completely new to JS.
<template>
<v-container fluid>
<v-btn @click="do_action()">{{title}}</v-btn>
<v-textarea v-model="response_message">
</v-textarea>
</v-container>
</template>
<script>
const { ipcRenderer } = require('electron')
export default {
props: ['title'],
data: function(){
return {
response_message: "Original Message"
}
},
methods: {
do_action: function() {
ipcRenderer.send('cmnd_foo')
}
},
}
ipcRenderer.on('cmnd_foo-reply', (event, a_new_message) => {
// obviously this.response_message isn't in scope...
// how can I get this intent to work
this.response_message = a_new_message
})
</script>