Make it safe to use sendSync
This commit is contained in:
parent
ac2e500cf7
commit
e78a02806e
3 changed files with 11 additions and 5 deletions
|
@ -1,9 +1,17 @@
|
|||
{EventEmitter} = require 'events'
|
||||
|
||||
binding = process.atomBinding 'ipc'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
||||
# Created by init.coffee.
|
||||
ipcRenderer = v8Util.getHiddenValue global, 'ipc'
|
||||
|
||||
# Delay the callback to next tick in case the browser is still in the middle
|
||||
# of sending a message while the callback sends a sync message to browser,
|
||||
# which can fail sometimes.
|
||||
ipcRenderer.emit = (args...) ->
|
||||
setTimeout (-> EventEmitter::emit.call ipcRenderer, args...), 0
|
||||
|
||||
ipcRenderer.send = (args...) ->
|
||||
binding.send 'ipc-message', [args...]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue