sindresorhus / electron-better-ipc

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

Add `ipc.callFocusedRenderer` method #10

Closed oportocala closed 4 years ago

oportocala commented 5 years ago

Closes https://github.com/sindresorhus/electron-better-ipc/issues/2

oportocala commented 5 years ago

No tests for this but also I could not find tests for the callRenderer, only mention is in the fixture

sindresorhus commented 5 years ago

This needs a test. You can find the callRenderer test here: https://github.com/sindresorhus/electron-better-ipc/blob/master/test/fixture/index.js And the logging is checked here: https://github.com/sindresorhus/electron-better-ipc/blob/master/test/fixture/test.js#L46

oportocala commented 5 years ago

Thanks for the review @sindresorhus! Will add the test.

sindresorhus commented 5 years ago

Bump :)

oportocala commented 5 years ago

@sindresorhus I've run into a bit of roadblock with the test.

I can't figure out how to get an answer from the renderer inside on win.on('focus' handler. I tried to add a sleep timer here thinking it doesn't have time to send a response before the test closes the Application but that didn't work.

I also tried commenting out the application close, await t.context.app.stop(); but that didn't help either.

Please see https://github.com/sindresorhus/electron-better-ipc/pull/10/commits/8e1a4ddbaf48d9ccb80489d5c0c155fa897d0eed

Thanks!