Skip to content

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

@Gikkman

Description

@Gikkman

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions