electron/renderer/api/lib/ipc.coffee
Cheng Zhao f8899242c5 No more plan for ipc.sendSync in browser.
I want the browser to be fully asynchronous, so sending synchronous
messages from browser to renderer will be unacceptable.
2013-04-23 22:21:49 +08:00

21 lines
587 B
CoffeeScript

EventEmitter = require('events').EventEmitter
ipc = process.atom_binding('ipc')
class Ipc extends EventEmitter
constructor: ->
process.on 'ATOM_INTERNAL_MESSAGE', (args...) =>
@emit(args...)
send: (args...) ->
ipc.send('ATOM_INTERNAL_MESSAGE', 'message', args...)
sendChannel: (args...) ->
ipc.send('ATOM_INTERNAL_MESSAGE', args...)
sendSync: (args...) ->
ipc.sendSync('ATOM_INTERNAL_MESSAGE_SYNC', 'sync-message', args...).result
sendChannelSync: (args...) ->
ipc.sendSync('ATOM_INTERNAL_MESSAGE_SYNC', args...).result
module.exports = new Ipc