Hi,
Im trying to fire an event on an action from my custom menu and listen for that event over in my other custom plugin created using react.
menu plugin:
module.exports = function(electronApp, menuState) {
return [{
label: ‘Configure’,
accelerator: ‘CommandOrControl+]’,
enabled: function() {
return true;
},
action: function() {
window.dispatchEvent(new Event(‘configure’));
}
}];
};
Here I’m trying to use the window object to fire the event. I’ve previously tried emitting the event using electronApp but I couldn’t find a way to inject this over in my React component.
Using the window implementation here is my custom plugin:
export default class ConfigurePlugin extends PureComponent {
constructor(props) {
super(props);
window.addEventListener('configure', (event) => {
console.log('event received');
});
}
componentDidMount() {
console.log('Mounted');
}
render() {
return <React.Fragment> </React.Fragment>
}
}
I know the plugin is being mounted correctly as ‘Mounted’ is printed to the console but the event is not being received.
Any help appreciated