sindresorhus / electron-better-ipc

Simplified IPC communication for Electron apps
MIT License
715 stars 60 forks source link

QUESTION: Any reason for mutating ipcRenderer / ipcMain? #11

Closed oriSomething closed 5 years ago

oriSomething commented 5 years ago
  1. Any reason for mutating ipcRenderer / ipcMain? (I'm asking that as if it would be using "prototype extensions" of browser techs)
  2. Wouldn't be better to export { ipcRenderer, ipcMain } instead of ipc which changed by the environment? (It's true, it's a bit cleaner, but they're still have different shape which mean, more confusion and not allowing creating proper type definitions)
sindresorhus commented 5 years ago
  1. I think I was just lazy as I also wanted to expose the native methods. In hindsight, I should have done it the other way around an assigned the native methods to my own exported object. This should be fixed. Help welcome :)
  2. I never considered the TypeScript case, but you're right, that does indeed make it more awkward (see https://github.com/sindresorhus/electron-better-ipc/pull/13/files#r275195838). I'm inclined to change it now. @BendingBender @CvX Thoughts?
BendingBender commented 5 years ago
1. I think I was just lazy as I also wanted to expose the native methods. In hindsight, I should have done it the other way around an assigned the native methods to my own exported object. This should be fixed. Help welcome :)

I think I'll fix it in #13.

2. I never considered the TypeScript case, but you're right, that does indeed make it more awkward (see [sindresorhus/electron-better-ipc/pull/13/files#r275195838](https://github.com/sindresorhus/electron-better-ipc/pull/13/files#r275195838)). I'm inclined to change it now.

I think that exposing two different exports is the way to go. It cleanly fixes the TS case. We could also provide two different entry points ('electron-better-ipc/renderer' and 'electron-better-ipc/main') but I dislike this approach due to ergonomics.

sindresorhus commented 5 years ago

Alright. Two different exports it is then. Thanks for chiming in.

sindresorhus commented 5 years ago

Alright. Two different exports it is then. Thanks for chiming in.