sindresorhus / electron-better-ipc

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

Simplify calling the focused window #2

Closed sindresorhus closed 4 years ago

sindresorhus commented 6 years ago

Issuehunt badges

Having to do this every time is slightly inconvenient:

const win = electron.BrowserWindow.getFocusedWindow();

(async () => {
    const emoji = await ipc.callRenderer(win, 'get-emoji', 'unicorn');
    console.log(emoji);
    //=> 'πŸ¦„'
})();

I'm thinking something like:

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

Thoughts?


IssueHunt Summary #### [ulken ulken](https://issuehunt.io/u/ulken) has been rewarded. ### Backers (Total: $40.00) - [issuehunt issuehunt](https://issuehunt.io/u/issuehunt) ($40.00) ### Submitted pull Requests - [#10 Add `ipc.callFocusedRenderer` method](https://issuehunt.io/r/sindresorhus/electron-better-ipc/pull/10) - [#27 Add `ipc.callFocusedRenderer`](https://issuehunt.io/r/sindresorhus/electron-better-ipc/pull/27) --- ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/sindresorhus/electron-better-ipc/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds. --- IssueHunt has been backed by the following sponsors. [Become a sponsor](https://issuehunt.io/membership/members)
IssueHuntBot commented 5 years ago

@issuehuntfest has funded $40.00 to this issue. See it on IssueHunt

oportocala commented 5 years ago

I took a stab at this: https://github.com/sindresorhus/electron-better-ipc/pull/10 This is my first time trying to contribute to OS. Please be gentle :)

IssueHuntBot commented 5 years ago

@oportocala has submitted a pull request. See it on IssueHunt

ulken commented 4 years ago

@sindresorhus What's the status of this? Is it being worked on? Is it still wanted?

If no one is working on it, I'd like to have a go at it.

ulken commented 4 years ago

I went ahead and did it anyhow. Hope it will bring you any value πŸ˜ƒ

issuehunt-oss[bot] commented 4 years ago

@sindresorhus has rewarded $36.00 to @ulken. See it on IssueHunt