electron/atom/renderer/api/lib/ipc.coffee

27 lines
691 B
CoffeeScript
Raw Normal View History

EventEmitter = require('events').EventEmitter
process = global.process
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...) ->
ipc.send 'ipc-message', [args...]
2013-04-23 13:52:19 +00:00
sendSync: (args...) ->
JSON.parse ipc.sendSync('ipc-message-sync', [args...])
2013-04-23 13:52:19 +00:00
2014-12-17 19:09:11 +00:00
sendToHost: (args...) ->
ipc.send 'ipc-message-host', [args...]
# Discarded
sendChannel: -> @send.apply this, arguments
sendChannelSync: -> @sendSync.apply this, arguments
module.exports = new Ipc