sindresorhus / electron-better-ipc

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

Add `ipc.callFocusedRenderer` #27

Closed ulken closed 4 years ago

ulken commented 4 years ago

Convenience wrapper around ipc.callRenderer. Implicitly calls focused window, as determined by electron.BrowserWindow.getFocusedWindow.

Before

const browserWindow = electron.BrowserWindow.getFocusedWindow();

(async () => {
    const emoji = await ipc.callRenderer(browserWindow, 'get-emoji', 'unicorn');
    console.log(emoji);
    //=> '🦄'
})();

After

(async () => {
    const emoji = await ipc.callFocusedRenderer('get-emoji', 'unicorn');
    console.log(emoji);
    //=> '🦄'
})();

Closes #2 Closes #10


IssueHunt Summary ### Referenced issues This pull request has been submitted to: - [#2: Simplify calling the focused window](https://issuehunt.io/repos/130656750/issues/2) --- IssueHunt has been backed by the following sponsors. [Become a sponsor](https://issuehunt.io/membership/members)
sindresorhus commented 4 years ago

Looks good. Thanks :)