]> khamidou — GitHub mirrors - electron.git/commitdiff
Prefer event.returnValue to event.result for sync messages.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 20 Sep 2013 13:24:04 +0000 (21:24 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 20 Sep 2013 13:37:00 +0000 (21:37 +0800)
docs/api/browser/ipc-browser.md
docs/api/renderer/ipc-renderer.md
renderer/api/lib/ipc.coffee

index 34ebda8a4dca07b8b8bfbd63e314c44eb4adb663..2edaa29463ae4a34619ee48c6be42400bacc70e7 100644 (file)
@@ -18,7 +18,7 @@ Emitted when renderer sent a message to the browser.
 * `routingId` Integer
 
 Emitted when renderer sent a synchronous message to the browser. The receiver
-should store the result in `event.result`.
+should store the result in `event.returnValue`.
 
 **Note:** Due to the limitation of `EventEmitter`, returning value in the
 event handler has no effect, so we have to store the result by using the
index cdeadf39f6809dc3ac8e92543914f31dc153a821..4076b93b395ebdf9a0d92f403114e16082b5bdcb 100644 (file)
@@ -30,7 +30,7 @@ An example of sending synchronous message from renderer to browser:
 // In browser:
 var ipc = require('ipc');
 ipc.on('browser-data-request', function(event, processId, routingId, message) {
-  event.result = 'THIS SOME DATA FROM THE BROWSER';
+  event.returnValue = 'THIS SOME DATA FROM THE BROWSER';
 });
 ```
 
index 28b9a9692d041750f86980b6d02dcd55cdda92ea..88b8c1c41585a108580e66c27dc6f7c5db93063f 100644 (file)
@@ -16,9 +16,11 @@ class Ipc extends EventEmitter
     ipc.send('ATOM_INTERNAL_MESSAGE', args...)
 
   sendSync: (args...) ->
-    ipc.sendSync('ATOM_INTERNAL_MESSAGE_SYNC', 'sync-message', args...).result
+    msg = ipc.sendSync('ATOM_INTERNAL_MESSAGE_SYNC', 'sync-message', args...)
+    msg.returnValue ? msg.result
 
   sendChannelSync: (args...) ->
-    ipc.sendSync('ATOM_INTERNAL_MESSAGE_SYNC', args...).result
+    msg = ipc.sendSync('ATOM_INTERNAL_MESSAGE_SYNC', args...)
+    msg.returnValue ? msg.result
 
 module.exports = new Ipc