Skip to content
New issue

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

Suggestion: Different send/listen definitions for main and renderer #2

Open
Gikkman opened this issue Nov 1, 2019 · 0 comments
Open

Comments

@Gikkman
Copy link

Gikkman commented Nov 1, 2019

I really like this library concept, and I fully agree with the outlined issue described in the philosophy part. But one thing I think would be a great enhancement would be to be able to define different events which ipcMain and ipcRenderer can send.

I saw that another typings library had that feature, so I forked this and tried to tinker it myself but my understanding of how to work with these types isn't enough.

Basically, I think it'd be helpful to do:

interface EventsFromMain {
  'msg-A': void;
}

interface EventsFromRenderer {
  'msg-B': void;
}

/* First generic indicates what types can be used for send methods, 
second generic indicates what can be used in listener methods */
const ipcRenderer: StrictIpcRenderer<EventsFromRenderer, EventsFromMain > = electron.ipcRenderer;
const ipcMain: StrictIpcMain<EventsFromMain, EventsFromRenderer> = electron.ipcMain;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant