Skip to content

Instantly share code, notes, and snippets.

@bushev
Last active March 4, 2019 02:22
Show Gist options
  • Save bushev/b74b645476a1cf887bbd54d6f148f57e to your computer and use it in GitHub Desktop.
Save bushev/b74b645476a1cf887bbd54d6f148f57e to your computer and use it in GitHub Desktop.

Add handleEvent method:

handleEvent(payload, sender, event) {

  this.metadata.webContents.send(event, payload);
}

Subscribe on event emit in method serviceCreated:

ipcMain.on('emit', async (event, notification) => {

  if (!this.metadata.webContents) this.metadata.webContents = event.sender;

  this.broker.emit(notification.event, notification.payload);
});

Finally, declare event handlers in a service schema definition:

events: {
  'compressor.*': this.handleEvent,
  'thumbnail.*': this.handleEvent
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment