electron/renderer/api/lib/ipc.coffee
Cheng Zhao e5afa72b4d Fail quietly when getting null renderer view.
It happens when the window is closing.
2013-12-05 23:34:43 +08:00

24 lines
636 B
CoffeeScript

EventEmitter = require('events').EventEmitter
ipc = process.atomBinding('ipc')
class Ipc extends EventEmitter
constructor: ->
process.on 'ATOM_INTERNAL_MESSAGE', (args...) =>
@emit args...
window.addEventListener 'unload', (event) ->
process.removeAllListeners 'ATOM_INTERNAL_MESSAGE'
send: (args...) ->
@sendChannel 'message', args...
sendChannel: (args...) ->
ipc.send 'ATOM_INTERNAL_MESSAGE', [args...]
sendSync: (args...) ->
@sendSync 'sync-message', args...
sendChannelSync: (args...) ->
JSON.parse ipc.sendSync('ATOM_INTERNAL_MESSAGE_SYNC', [args...])
module.exports = new Ipc