Allow web frame methods to return async promises
This commit is contained in:
parent
cf0cd5b50b
commit
124fbdbd74
1 changed files with 7 additions and 1 deletions
|
@ -39,7 +39,13 @@ electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_SYNC_WEB_FRAME_METHOD', (eve
|
||||||
|
|
||||||
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
||||||
const responseCallback = function (result) {
|
const responseCallback = function (result) {
|
||||||
event.sender.send(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, result)
|
Promise.resolve(result)
|
||||||
|
.then((resolvedResult) => {
|
||||||
|
event.sender.send(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, resolvedResult)
|
||||||
|
})
|
||||||
|
.catch((resolvedError) => {
|
||||||
|
console.error(`An async web frame method (${method}) returned a promise that threw an error: `, resolvedError)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
args.push(responseCallback)
|
args.push(responseCallback)
|
||||||
electron.webFrame[method].apply(electron.webFrame, args)
|
electron.webFrame[method].apply(electron.webFrame, args)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue