electron-typescript-ipc icon indicating copy to clipboard operation
electron-typescript-ipc copied to clipboard

Make the message subscription return an optional unsubscribe callback

Open wewei opened this issue 11 months ago • 1 comments

Hi, @JichouP , thanks for building this handy package to add TypeScript support for electron IPC. When I was using it, I find there's no way to unsubscribe a message from main. I propose this change to let the on.xxx function return an optional callback, so that the renderer code can unsubscribe the message channel when it's no longer needed.

I also made a small change in the build scripts, use rimraf, which is cross platform, to replace the POSIX command rm -rf. With this change, the package can be built on Windows.

Feel free to comments, and I'll make changes accordingly.

wewei avatar Mar 27 '24 05:03 wewei

@wewei Thank you for your contribution. It looks good to me!

Did it work correctly without changing the return type here? https://github.com/JichouP/electron-typescript-ipc/blob/bf61ffc/src/index.ts#L19

JichouP avatar Mar 30 '24 02:03 JichouP